feat(v4, ci): the fault dump on a node's stop, and the EMERGENCY diagnostic build after a failed stage

Captain Bob's CI directive (2026-11-17) and the design he ruled point by point
(docs/v4.0.0/plans/2026-11-17-emergency-diagnostic-build.md).

- v4/system/dump.c, v4/include/v4/dump.h: what a node was doing when it stopped -- the fault's kind,
  address and count; P A B; the data stack, T first; the return stack, R first, each entry named by
  the word it falls in (the backtrace; ROM and below-every-word said so); the running line. Bounded
  dictionary walk; no C library. Ruled: every build, on a stop only (a handled fault keeps its line).
- kernel/src/v4/sk_v4.c: the dump before each of the three halts (not started; POST's blocks not
  let go; a node stopped on a fault) -- Hera and any stopped node. kernel/Makefile links dump.o.
- scripts/nightly.sh diagnose [<stage>]: after a failed stage, that configuration built again with
  EMERGENCY_CONSOLE_ENABLED=1 -- build only, nothing booted (ruled) -- its artifacts kept in
  logs/<TS>/diagnose/ only from a build that passed, with a README saying how to launch it with
  --log-level=debug. Always exits 0: evidence, never a result. The protocol runs it after a failed
  stage and still exits with that stage's code; acceptance.yml, nightly.yml and release.yml run it
  `if: failure()`, before the logs are kept. Any failed stage triggers it (ruled).
- capsules/BLOCK_MAP.md: as the build writes it -- the v4:physics.4th row, missing since 28ffed8f
  (ruled: commit the regenerated map).
- Test first: test_dump.c failed with no dump.c (logs/20261117-dump), then 15 checks at both widths
  and under ASan+UBSan. The diagnose stage: a real EMERGENCY amd64 build; a failing build exits 0 and
  keeps no artifacts (a defect found and fixed this way); the protocol path keeps the stage's exit.
- Also the write-up of the regression at 046ce0be, for ruling.

Not yet: acceptance on a clean tree (the next run); the kernel's stop wiring is compile-tested only
-- no boot reaches a stop on purpose.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
This commit is contained in:
Claude
2026-11-17 19:14:40 +00:00
parent 3376255930
commit 45b11aec25
13 changed files with 632 additions and 7 deletions
+24
View File
@@ -34,6 +34,7 @@
#include "starkernel/timer.h"
#include "v4/boot.h"
#include "v4/fabric.h"
#include "v4/dump.h"
#include "v4/manage.h"
#include "v4/mesh.h"
#include "starkernel/kmalloc.h"
@@ -196,6 +197,26 @@ static void sk_v4_out(const char *text, unsigned len)
for (i = 0; i < len; i++) console_putc(text[i]);
}
/* The fault dump (v4/dump.h; plan 2026-11-17-emergency-diagnostic-build, ruled by Captain Bob 2026-11-17:
* every build, on a stop only): before the kernel halts on a node that stopped, it says what Hera -- and
* any other node that is stopped -- was doing: the fault, P A B, both stacks, the return stack named by
* word (the backtrace), and the line that was running. */
static void sk_v4_dump_out(void *self, const char *s, unsigned n) { (void)self; sk_v4_out(s, n); }
static void sk_v4_dump(const char *line, unsigned len)
{
unsigned k;
for (k = 0; k < SK_V4_PLACES; k++) {
v4_fabric_node *x = v4_fabric_node_at(&sk_v4_mesh.f, k);
if (!x || (k != sk_v4_mesh.hera_place && !x->n.stopped)) continue;
console_puts("V4 DUMP: the node at place ");
console_putc((char)('0' + (int)(k / 10u))); console_putc((char)('0' + (int)(k % 10u)));
console_puts(k == sk_v4_mesh.hera_place ? " (Hera)\n" : "\n");
v4_dump_node(&x->n, &sk_v4_image, k == sk_v4_mesh.hera_place ? line : 0,
k == sk_v4_mesh.hera_place ? len : 0u, sk_v4_dump_out, 0);
}
}
/* a character for a line that reads the keyboard, when there is one: the
* serial line or any keyboard (docs/v4.0.0/STICK.md 5.4) */
static int sk_v4_key(void)
@@ -333,6 +354,7 @@ void sk_v4_boot(void (*chain)(void), const BootDisk *boot_disk)
blk_subsys_init(sk_v4_post_blk_ram, sizeof(sk_v4_post_blk_ram));
if (!v4_mesh_boot(&sk_v4_mesh)) {
console_println("StarForth v4: not started");
sk_v4_dump(0, 0u);
sk_v4_stop(); /* #177: halts, not a 100% spin */
}
if (chain) {
@@ -341,6 +363,7 @@ void sk_v4_boot(void (*chain)(void), const BootDisk *boot_disk)
chain();
if (sk_v4_tell("EMPTY-BUFFERS", 13) != V4_TEXT_COMPLETED) {
console_println("StarForth v4: the node did not let go of POST's blocks");
sk_v4_dump("EMPTY-BUFFERS", 13u);
sk_v4_stop(); /* #177: halts, not a 100% spin */
}
}
@@ -405,6 +428,7 @@ void sk_v4_prompt(void)
else if (how == V4_BOOT_LINE_REFUSED) console_puts("Message refused\n ERROR\n"); /* the node's wire is full: error 19's words */
else if (how == V4_BOOT_LINE_STOPPED) {
console_println("StarForth v4: the node stopped on a fault");
sk_v4_dump(sk_v4_text, (unsigned)len);
sk_v4_stop(); /* #177: halts, not a 100% spin */
}
}