Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aien-architecture-mv/patches/6dc0946c862cd15d # aien-architecture-mv Canonical architecture for the AIEN ecosystem: flows, boundaries, ADRs, and the map from design to implementation repositories. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers ## GitHub aien-dev/aien-architecture-mv#122 (code only) closed derived `6dc0946c862cd15d` #122 Imported from GitHub aien-dev/aien-architecture-mv#122 (code only) GitHub's metadata for this pull request is unavailable: its state is DERIVED from the commits (merged: the head is reachable from this project's main; open: GitHub kept a merge ref; else closed). Base `89fda22daf3ddb149c82a36efdc89bc087ad2f0b` · Head `b6b16a2a75ec09032d49f202862a010b790983e9` ### Apply it ``` git checkout -b patch-6dc0946c862cd15d 89fda22daf3ddb149c82a36efdc89bc087ad2f0b curl -fsSL https://interplane.io/drakestapleton/aien-architecture-mv/patches/6dc0946c862cd15d.patch | git am ``` Raw patch (mbox) · Diff ### Provenance This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record: ``` github-import 1 aien-dev/aien-architecture-mv 122 b6b16a2a75ec09032d49f202862a010b790983e9 ``` ``` {"kind":"github-import","owner":"aien-dev","repo":"aien-architecture-mv","number":122,"url":"https://github.com/aien-dev/aien-architecture-mv/pull/122","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:37:44Z","metadata":"unavailable","state_derived":true} ``` ### Changes ``` diff --git a/docs/CRUMB_PROTOCOL_RFC_0002.md b/docs/CRUMB_PROTOCOL_RFC_0002.md index c51cef4..245352b 100644 --- a/docs/CRUMB_PROTOCOL_RFC_0002.md +++ b/docs/CRUMB_PROTOCOL_RFC_0002.md @@ -134,17 +134,18 @@ This RFC closes the gap for **all linked worktrees of one repository on one file ## 9. Tests (the feature is not done until these run) -| # | Test | Where | -|---|---|---| -| T1 | Cross-worktree visibility: A claims `src/runtime.c`, B's sniff from worktree B shows it | `tools/crumb/test.sh` | -| T2 | Cross-worktree conflict: B's claim of the same target exits 2 | same | -| T3 | Release: A closes, B's claim succeeds | same | -| T4 | Independent targets: both claims survive | same | -| T5 | Concurrent mutation: 8 parallel distinct claims all survive; 8 same-target claims yield exactly one success | same | -| T6 | TTL/crash: expired lock pruned, reclaimable | same | -| T7 | Path normalization: two absolute worktree paths -> one lock identity | same | -| T8 | Legacy `.crumb.local` read/import with provenance, never overriding newer shared state | same | -| T9 | Continuation revalidation: checkpoint at C, advance the repo, resume reports STALE/SUPERSEDED and status NEEDS_REVIEW | `tools/crumb/test-continuation.sh` | +| # | Test | Where | Result (2026-10-04) | +|---|---|---|---| +| T1 | Cross-worktree visibility: A claims `src/runtime.c`, B's sniff from worktree B shows it | `tools/crumb/test.sh` | PASS (`make -C tools/crumb test`, 0 FAIL) | +| T2 | Cross-worktree conflict: B's claim of the same target exits 2 | same | PASS (`make -C tools/crumb test`, 0 FAIL) | +| T3 | Release: A closes, B's claim succeeds | same | PASS (`make -C tools/crumb test`, 0 FAIL) | +| T4 | Independent targets: both claims survive | same | PASS (`make -C tools/crumb test`, 0 FAIL) | +| T5 | Concurrent mutation: 8 parallel distinct claims all survive; 8 same-target claims yield exactly one success | same | PASS (`make -C tools/crumb test`, 0 FAIL) | +| T6 | TTL/crash: expired lock pruned, reclaimable | same | PASS (`make -C tools/crumb test`, 0 FAIL) | +| T7 | Path normalization: two absolute worktree paths -> one lock identity | same | PASS (`make -C tools/crumb test`, 0 FAIL) | +| T8 | Legacy `.crumb.local` read/import with provenance, never overriding newer shared state | same | PASS (`make -C tools/crumb test`, 0 FAIL) | +| T9 | Continuation revalidation: checkpoint at C, advance the repo, resume reports STALE/SUPERSEDED and status NEEDS_REVIEW | `tools/crumb/test-continuation.sh` | PASS (8 checks; STALE repo HEAD + NEEDS_REVIEW; SKIP prints NOT_RUN where jq or cc.sh is absent) | +| E1 | `crumb explain`: every section header, nearest `.crumb`, commits, locks and whispers, continuation surfaced by `owned_paths` and by `scope`, unrelated continuation ignored, missing path fails | `tools/crumb/test.sh` | PASS (15 checks) | Results are reported PASS / FAIL / NOT_RUN per test in the merging PR; nothing unrun is called PASS. diff --git a/tools/crumb/Makefile b/tools/crumb/Makefile index ab83839..9162887 100644 --- a/tools/crumb/Makefile +++ b/tools/crumb/Makefile @@ -7,6 +7,7 @@ crumb: crumb.c test: crumb sh test.sh ./crumb + sh test-continuation.sh ./crumb clean: rm -f crumb diff --git a/tools/crumb/crumb.c b/tools/crumb/crumb.c index 6f6fac8..5b756d0 100644 --- a/tools/crumb/crumb.c +++ b/tools/crumb/crumb.c @@ -1296,6 +1296,247 @@ static int cmd_backfill(const char *root, const char *since, int dry) { printf("backfill %s (%s, %zu commits%s): %d crumb dirs, updated %d, unchanged %d, ledger git entries %d, lane entries %d, dirs truncated in doc %d\n", r, repo, g_nc, since ? ", since given" : "", st.dirs, st.updated, st.unchanged, st.git_entries, st.lane_entries, st.truncated_dirs); return 0; } +static void usage(void); +/* ---------- RFC-0002 section 7: crumb explain ---------- */ +#define EXPL_COMMITS 10 +#define EXPL_WHISPERS 5 +static void print_strs(const char *label, const J *a, int max) { /* array of strings, or a single string */ + if (!a) return; + if (a->t == JSTR) { printf(" %s: %s\n", label, a->s); return; } + if (a->t != JARR) return; + for (size_t i = 0; i < a->n && (int)i < max; i++) { + if (a->v[i]->t == JSTR) printf(" %s: %s\n", label, a->v[i]->s); + else { char *d = jdump(a->v[i]); d[strcspn(d, "\n")] = 0; printf(" %s: %s\n", label, d); } + } +} +static J *load_crumb(const char *dir) { char *cp = pjoin(dir, ".crumb"), *txt = slurp(cp); J *c = txt ? jparse(txt) : NULL; return c && c->t == JOBJ ? c : NULL; } +/* does a continuation path entry (e.g. "tools/crumb/", "repo tools/crumb/.crumb") mention rel? */ +static int path_mentions(const char *entry, const char *rel) { + if (!strcmp(rel, ".")) return 1; + size_t rl = strlen(rel); + for (const char *s = entry; (s = strstr(s, rel)); s++) { + int before = s == entry || s[-1] == ' ' || s[-1] == '/' || s[-1] == '"'; + char a = s[rl]; + int after = !a || a == '/' || a == ' ' || a == '"'; + if (before && after) return 1; + } + /* entry is an ancestor of rel (owner of the parent directory) */ + size_t el = strlen(entry); + while (el && entry[el - 1] == '/') el--; + return el > 0 && el < rl && !strncmp(entry, rel, el) && rel[el] == '/'; +} +static int cont_matches(const J *c, const char *rel) { + J *co = jget(c, "coordination"); + static const char *keys[] = { "scope", "owned", "owned_paths", NULL }; + if (!co || co->t != JOBJ) return 0; + for (int k = 0; keys[k]; k++) { + J *a = jget(co, keys[k]); + if (a && a->t == JARR) for (size_t i = 0; i < a->n; i++) if (a->v[i]->t == JSTR && path_mentions(a->v[i]->s, rel)) return 1; + } + return 0; +} +static const char *cont_when(const J *c) { + J *id = jget(c, "identity"); + const char *s = id ? jstrval(id, "sealed_at") : NULL; + if (!s && id) s = jstrval(id, "created_at"); + return s ? s : ""; +} +static int cmd_explain(const char *target) { + char r[PATH_MAX]; + if (!realpath(target, r)) die("no such file or directory: %s", target); + struct stat st; if (stat(r, &st)) die("cannot stat %s", target); + char *abs = xstrdup(r), *dir = S_ISDIR(st.st_mode) ? xstrdup(r) : dir_of(r); + Plane *p = plane_resolve(dir); + const char *env = getenv("CRUMB_COORD_ROOT"); + char *top = p ? p->top : NULL, *rel = NULL; + if (p) { + size_t tl = strlen(top); + rel = abs[tl] ? xstrdup(abs + tl + 1) : xstrdup("."); + } else rel = xstrdup(base_of(abs)); + char *store = p ? p->store : (env && *env ? xstrdup(env) : NULL); + printf("EXPLAIN %s\n repository path: %s\n", abs, rel); + + /* 1. nearest .crumb */ + printf("== NEAREST CRUMB ==\n"); + char *d = xstrdup(dir), *nearest = NULL; J *nc = NULL; + for (;;) { + if ((nc = load_crumb(d))) { nearest = xstrdup(d); break; } + if (top && !strcmp(d, top)) break; + char *up = dir_of(d); if (!strcmp(up, d) || !strcmp(up, ".")) break; + if (!*up) { free(up); up = xstrdup("/"); if (!strcmp(d, "/")) break; } + free(d); d = up; + } + if (nc) { + printf(" file: %s/.crumb\n name: %s\n layer: %s\n purpose: %s\n", nearest, sv(nc, "name"), sv(nc, "layer"), sv(nc, "purpose")); + J *inv = jget(nc, "invariants"); if (inv) print_strs("invariant", inv, 50); else printf(" invariant: (none)\n"); + J *ex = jget(nc, "exports"); if (ex) print_strs("export", ex, 50); else printf(" export: (none)\n"); + J *rl = jget(nc, "related"); if (rl) print_strs("related", rl, 50); else printf(" related: (none)\n"); + } else printf(" (no .crumb found at or above this path)\n"); + + /* 2. inherited invariants */ + printf("== INHERITED INVARIANTS ==\n"); + int any = 0; + if (nearest) { + char *u = dir_of(nearest); + while (strcmp(u, nearest) && strcmp(u, ".")) { + if (top && strlen(u) < strlen(top)) break; + J *pc = load_crumb(u); + if (pc) { J *inv = jget(pc, "invariants"); if (inv && inv->t == JARR) for (size_t i = 0; i < inv->n; i++) if (inv->v[i]->t == JSTR) { printf(" from %s/.crumb: %s\n", u, inv->v[i]->s); any = 1; } } + if (top && !strcmp(u, top)) break; + char *nx = dir_of(u); if (!strcmp(nx, u)) break; u = nx; + } + } + if (!any) printf(" (none)\n"); + + /* 3. shared coordination */ + printf("== SHARED COORDINATION ==\n"); + if (p) { + Txn *t = txn_begin(p, 0); txn_prune(t); + char *dr = !strcmp(rel, ".") ? xstrdup(".") : (S_ISDIR(st.st_mode) ? xstrdup(rel) : dir_of(rel)); + any = 0; + for (size_t i = 0; i < t->n; i++) if (t->r[i]->agent && !t->r[i]->dead && jget(t->r[i]->root, "updated_at")) { print_agent(t->r[i]->root, sv(t->r[i]->root, "agent")); any = 1; } + if (!any) printf(" agents: (none)\n"); + any = 0; + for (size_t i = 0; i < t->n; i++) if (!t->r[i]->agent) { + J *lk = jget(t->r[i]->root, "locks"); + if (lk && lk->t == JOBJ) for (size_t k = 0; k < lk->n; k++) { + const char *kk = lk->k[k]; char *kd = key_dir(kk); + if (!strcmp(dr, ".") || !strcmp(kd, dr) || path_mentions(kk, rel)) { print_lock(kk, lk->v[k]); any = 1; } + } + } + if (!any) printf(" locks: (none)\n"); + J *wh = jget(dir_rec(t, dr)->root, "whispers"); any = 0; + if (wh && wh->t == JARR) for (size_t i = wh->n > EXPL_WHISPERS ? wh->n - EXPL_WHISPERS : 0; i < wh->n; i++) { + printf(" whisper %s -> %s: %s [%s]\n", sv(wh->v[i], "from"), jstrval(wh->v[i], "to") ? jstrval(wh->v[i], "to") : "all", sv(wh->v[i], "message"), sv(wh->v[i], "timestamp")); any = 1; + } + if (!any) printf(" whispers: (none)\n"); + txn_end(t, 0); + } else if (store) printf(" coordination root %s (no repository)\n", store); + else printf(" shared coordination: none (not a git repository)\n"); + + /* 4. commits */ + printf("== RECENT COMMITS ==\n"); + if (p) { + char q[PATH_MAX + 64]; snprintf(q, sizeof q, "log --oneline -%d -- '%s'", EXPL_COMMITS, rel); + char *lg = run_git_full(top, q); + if (*lg) { for (char *s = strtok(lg, "\n"); s; s = strtok(NULL, "\n")) printf(" %s\n", s); } else printf(" (no commits touch this path)\n"); + } else printf(" (not a git repository)\n"); + if (nc) { + J *ex = jget(nc, "extensions"), *pv = ex && ex->t == JOBJ ? jget(ex, "provenance") : NULL, *en = pv && pv->t == JOBJ ? jget(pv, "entries") : NULL; + if (en && en->t == JARR) for (size_t i = 0; i < en->n && i < EXPL_COMMITS; i++) { + const char *sh = jstrval(en->v[i], "sha"); int dup = 0; + for (size_t j = 0; sh && j < i; j++) if (!strcmp(sv(en->v[j], "sha"), sh)) dup = 1; + if (sh && !dup) printf(" named in .crumb: %s %s\n", sh, sv(en->v[i], "subject")); + } + } + + /* 5. evidence references */ + printf("== EVIDENCE REFERENCES ==\n"); + any = 0; + if (nc) { + J *ex = jget(nc, "extensions"); + if (ex && ex->t == JOBJ) { + J *ev = jget(ex, "evidence"); + if (ev) { print_strs("crumb evidence", ev, 20); any = 1; } + J *pv = jget(ex, "provenance"), *en = pv && pv->t == JOBJ ? jget(pv, "entries") : NULL; + if (en && en->t == JARR) for (size_t i = 0; i < en->n && i < EXPL_COMMITS; i++) { long pr = jlong(en->v[i], "pr", 0); int dup = 0; for (size_t j = 0; j < i; j++) if (jlong(en->v[j], "pr", 0) == pr) dup = 1; if (pr && !dup) { printf(" crumb pr: #%ld (%s)\n", pr, sv(en->v[i], "sha")); any = 1; } } + } + } + /* 6. continuations */ + J *best = NULL; char *bestf = NULL; int nmatch = 0; + if (store) { + char **f = NULL; size_t n = 0; char *cd = pjoin(store, "continuations"); + collect_json(cd, &f, &n); + for (size_t i = 0; i < n; i++) { + char *txt = slurp(f[i]); J *c = txt ? jparse(txt) : NULL; + if (!c || c->t != JOBJ || !jget(c, "identity") || !cont_matches(c, rel)) continue; + nmatch++; + J *ev = jget(c, "evidence"); + if (ev && ev->t == JOBJ) { + static const char *ek[] = { "commits", "prs", "receipts", NULL }; + for (int k = 0; ek[k]; k++) { J *a = jget(ev, ek[k]); if (a && a->t == JARR) for (size_t j = 0; j < a->n && j < 10; j++) if (a->v[j]->t == JSTR) { printf(" continuation %s %s: %s\n", sv(jget(c, "identity"), "checkpoint_id"), ek[k], a->v[j]->s); any = 1; } } + J *ts = jget(ev, "tests"); + if (ts && ts->t == JARR) for (size_t j = 0; j < ts->n && j < 10; j++) { printf(" continuation test: %s -> %s\n", sv(ts->v[j], "name"), sv(ts->v[j], "result")); any = 1; } + } + if (!best || strcmp(cont_when(c), cont_when(best)) > 0) { best = c; bestf = f[i]; } + } + } + if (!any) printf(" (none)\n"); + printf("== NEWEST CONTINUATION ==\n"); + if (!best) printf(" (none touches this path)\n"); + else { + J *id = jget(best, "identity"), *st2 = jget(best, "state"), *items = st2 && st2->t == JOBJ ? jget(st2, "items") : st2; + printf(" id: %s sealed: %s by: %s (%d matching, showing 1)\n file: %s\n reason: %s\n", sv(id, "checkpoint_id"), cont_when(best), sv(id, "created_by"), nmatch, bestf, sv(id, "reason")); + J *rv = jget(best, "revalidation"); if (rv) printf(" revalidation: %s\n", sv(rv, "status")); + if (items && items->t == JARR) for (size_t i = 0; i < items->n; i++) printf(" [%s] %s\n", sv(items->v[i], "tag"), sv(items->v[i], "claim")); + } + return 0; +} + +/* ---------- RFC-0002 section 7: checkpoint / resume (thin wrappers around cc.sh) ---------- */ +static char *cc_path(void) { + const char *e = getenv("CRUMB_CC"); + if (e && *e) return xstrdup(e); + const char *h = getenv("HOME"); + if (!h || !*h) die("HOME is not set; set CRUMB_CC to the path of cc.sh"); + size_t n = strlen(h) + 64; char *s = xmalloc(n); + snprintf(s, n, "%s/.claude/skills/checkpoint/scripts/cc.sh", h); return s; +} +static void cc_env(Plane *p) { /* records must land in /continuations */ + const char *env = getenv("CRUMB_COORD_ROOT"); + if (p) setenv("CRUMB_COORD_ROOT", p->store, 1); + else if (!(env && *env)) die("no repository context: run inside a git checkout or set CRUMB_COORD_ROOT"); + char self[PATH_MAX]; ssize_t n = readlink("/proc/self/exe", self, sizeof self - 1); + if (n > 0 && !getenv("CRUMB_BIN")) { self[n] = 0; setenv("CRUMB_BIN", self, 1); } +} +static char *cc_script(void) { + char *cc = cc_path(); + if (access(cc, X_OK) != 0) die("cc.sh not found or not executable at %s (the checkpoint skill; set CRUMB_CC to override)", cc); + return cc; +} +static char *shq(const char *s) { Buf q = {0}; bstr(&q, "'"); for (; *s; s++) { if (*s == '\'') bstr(&q, "'\\''"); else bput(&q, s, 1); } bstr(&q, "'"); return q.p; } +static int cmd_checkpoint(int a, char **v) { + const char *agent = NULL, *reason = NULL, *seal = NULL; + for (int i = 0; i < a; i++) { + if (!strcmp(v[i], "--reason") && i + 1 < a) reason = v[++i]; + else if (!strcmp(v[i], "--seal") && i + 1 < a) seal = v[++i]; + else if (!agent && v[i][0] != '-') agent = v[i]; + else usage(); + } + if (!agent && !seal) usage(); + Plane *p = plane_resolve("."); cc_env(p); + char *cc = cc_script(); const char *ag = agent ? agent : (getenv("CC_AGENT") ? getenv("CC_AGENT") : "claude"); + setenv("CC_AGENT", ag, 1); + if (seal) execl(cc, cc, "seal", seal, ag, (char *)NULL); + else { + char *top = p ? p->top : absdir("."); + Buf cmd = {0}; char *q1 = shq(cc), *q2 = shq(agent), *q3 = shq(top); + bstr(&cmd, q1); bstr(&cmd, " new "); bstr(&cmd, q2); bstr(&cmd, " "); bstr(&cmd, q3); + FILE *f = popen(cmd.p, "r"); if (!f) die("cannot run %s", cc); + char out[PATH_MAX + 2]; size_t n = fread(out, 1, sizeof out - 1, f); out[n] = 0; + if (pclose(f) != 0 || !n) die("cc.sh new failed"); + out[strcspn(out, "\n")] = 0; + if (reason) { + Buf c2 = {0}; char *qr = shq(reason), *qo = shq(out); + bstr(&c2, "tmp=$(mktemp) && jq --arg r "); bstr(&c2, qr); bstr(&c2, " '.identity.reason=$r' "); bstr(&c2, qo); + bstr(&c2, " > \"$tmp\" && mv \"$tmp\" "); bstr(&c2, qo); + if (system(c2.p) != 0) die("could not record the reason (jq missing?)"); + } + printf("%s\n", out); + fprintf(stderr, "fill in the record, then: crumb checkpoint --seal %s\n", agent); + return 0; + } + die("cannot exec %s: %s", cc, strerror(errno)); + return 1; +} +static int cmd_resume(const char *id) { + Plane *p = plane_resolve("."); cc_env(p); + char *cc = cc_script(); + execl(cc, cc, "resume", id, (char *)NULL); + die("cannot exec %s: %s", cc, strerror(errno)); + return 1; +} + static long ttl_arg(const char *s, long dflt) { if (!s) return dflt; char *e; long v = strtol(s, &e, 10); if (*e || v < 0) die("bad ttl: %s", s); return v; } static void usage(void) { fputs("usage: crumb ...\n" @@ -1307,6 +1548,9 @@ static void usage(void) { " whisper [prio] [target_file]\n" " close [action] [msg] release lock, add history vector, optional whisper\n" " sniff what to read before touching a directory\n" + " explain nearest + inherited crumbs, coordination, commits, evidence, newest continuation\n" + " checkpoint [--reason R] new Continuation Crumb (wraps cc.sh); then checkpoint --seal [agent]\n" + " resume print record, revalidate against live repos (wraps cc.sh)\n" " list [path] live scents, locks, whispers under path\n" " validate [path] check .crumb files against RFC-0001 required fields\n", stderr); exit(1); @@ -1330,6 +1574,9 @@ int main(int argc, char **argv) { if (!strcmp(c, "whisper") && a >= 4) return cmd_whisper(v[0], v[1], v[2], v[3], a > 4 ? v[4] : NULL, a > 5 ? v[5] : NULL); if (!strcmp(c, "close") && a >= 3) return cmd_close(v[0], v[1], v[2], a > 3 ? v[3] : "modify", a > 4 ? v[4] : NULL); if (!strcmp(c, "sniff") && a >= 2) return cmd_sniff(v[0], v[1]); + if (!strcmp(c, "explain") && a == 1) return cmd_explain(v[0]); + if (!strcmp(c, "checkpoint")) return cmd_checkpoint(a, v); + if (!strcmp(c, "resume") && a == 1) return cmd_resume(v[0]); if (!strcmp(c, "list") || !strcmp(c, "validate")) { int val = !strcmp(c, "validate"); Tot t = {0, 0, 0}; char *r = absdir(a ? v[0] : "."); diff --git a/tools/crumb/test-continuation.sh b/tools/crumb/test-continuation.sh new file mode 100644 index 0000000..709ff86 --- /dev/null +++ b/tools/crumb/test-continuation.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# T9 (RFC-0002 section 9): Continuation revalidation. usage: sh test-continuation.sh ./crumb +# checkpoint at commit C, advance the repo, resume must report STALE for repo HEAD and status NEEDS_REVIEW. +C=${1:-./crumb}; C=$(cd "$(dirname "$C")" && pwd)/$(basename "$C") +CC=${CRUMB_CC:-$HOME/.claude/skills/checkpoint/scripts/cc.sh} +if [ ! -x "$CC" ] || ! command -v jq >/dev/null 2>&1; then echo "SKIP T9 (needs jq and cc.sh at $CC): NOT_RUN"; exit 0; fi +T=$(mktemp -d); trap 'rm -rf "$T"' EXIT +fail=0; ok() { echo "PASS $1"; }; bad() { echo "FAIL $1"; fail=1; } +export HOME="$T/home"; mkdir -p "$HOME" # seal leaves whispers under $HOME/handoffs: keep them in scratch +export CRUMB_CC="$CC" CRUMB_SESSION=t9-agent; unset CRUMB_COORD_ROOT CC_STORE +mkdir -p "$T/r/src" "$HOME/handoffs"; cd "$T/r" || exit 1 +git init -q -b main . && echo a > src/a.c && git add -A && git -c user.name=t -c user.email=t@t commit -qm init +C0=$(git rev-parse HEAD) +STORE=$(git rev-parse --absolute-git-dir)/crumb/v1 + +out=$("$C" checkpoint t9-agent --reason "t9 test") ; rc=$? +[ $rc -eq 0 ] && [ -f "$out" ] && case "$out" in "$STORE/continuations/"*) true;; *) false;; esac && ok "T9 checkpoint creates record in /continuations" || { bad "T9 checkpoint ($out)"; exit 1; } +id=$(basename "$out" .json) +jq -e '.identity.reason=="t9 test" and .identity.created_by=="t9-agent" and (.identity.repos[0].commit=="'"$C0"'")' "$out" >/dev/null && ok "T9 record pins HEAD and reason" || bad "T9 pin" +tmp="$out.t"; jq '.identity.project="t9" | .mission.current_goal="g" | .mission.milestone="m" | .mission.definition_of_done=["done"] + | .state.items=[{"tag":"OPEN","claim":"nothing yet"}] | .execution.current_task="t" | .execution.next_tasks=[{"id":"n1","task":"x"}] + | .resume.first_action="look" | .resume.validation_before_work=["git status"] | .resume.bootstrap_prompt="continue"' "$out" > "$tmp" && mv "$tmp" "$out" +seal=$("$C" checkpoint --seal "$id" t9-agent 2>&1); echo "$seal" | grep -q "SEALED $id" && ok "T9 seal succeeds" || bad "T9 seal: $seal" +[ "$(cat "$STORE/continuations/LATEST" 2>/dev/null)" = "$id" ] && ok "T9 LATEST updated in the shared store" || bad "T9 LATEST" + +echo more > src/b.c && git add -A && git -c user.name=t -c user.email=t@t commit -qm "advance" +res=$("$C" resume "$id" 2>&1) +echo "$res" | grep -q '^STALE .*repo\..*\.HEAD' && ok "T9 resume prints STALE for repo HEAD" || bad "T9 STALE line" +echo "$res" | grep -q '^status: NEEDS_REVIEW' && ok "T9 resume status NEEDS_REVIEW" || bad "T9 status" +[ "$(jq -r .revalidation.status "$STORE/continuations/$id.json")" = NEEDS_REVIEW ] && ok "T9 findings recorded in the record" || bad "T9 recorded" +CRUMB_CC="$T/missing/cc.sh" "$C" resume "$id" 2>&1 | grep -q 'cc.sh not found.*missing/cc.sh' && ok "T9 missing cc.sh gives a clear error naming the path" || bad "T9 missing cc.sh" +exit $fail diff --git a/tools/crumb/test.sh b/tools/crumb/test.sh index 0b5c98e..47bbe68 100644 --- a/tools/crumb/test.sh +++ b/tools/crumb/test.sh @@ -106,4 +106,32 @@ HOME="$T/home" "$C" backfill . >/dev/null grep -q '"pr": 7' src/.crumb && grep -q "\"sha\": \"$sha\"" src/.crumb && grep -q backfill-git src/.crumb && ok "backfill: PR 7 + sha in src/.crumb" || bad "backfill entry" grep -q "$sha #7" docs/crumbs/BACKFILL.md && ok "BACKFILL.md lists commit" || bad "BACKFILL.md" HOME="$T/home" "$C" backfill . | grep -q 'updated 0' && HOME="$T/home" "$C" backfill . | grep -q 'BACKFILL.md: unchanged' && ok "backfill idempotent" || bad "backfill idempotent" +# ---- RFC-0002 section 7: crumb explain ---- +cd "$T/r" || exit 1 +ex=$("$C" explain src) +for h in 'NEAREST CRUMB' 'INHERITED INVARIANTS' 'SHARED COORDINATION' 'RECENT COMMITS' 'EVIDENCE REFERENCES' 'NEWEST CONTINUATION'; do + echo "$ex" | grep -q "^== $h ==" && ok "explain prints section: $h" || bad "explain section: $h" +done +echo "$ex" | grep -q 'purpose: Hand written C sources' && echo "$ex" | grep -q 'invariant: no globals' && ok "explain shows nearest .crumb purpose + invariants" || bad "explain nearest" +echo "$ex" | grep -q 'feat: add b (#7)' && ok "explain lists commits touching the path" || bad "explain commits" +"$C" explain src/a.c | grep -q 'repository path: src/a.c' && ok "explain accepts a file" || bad "explain file" +echo "$ex" | grep -q '(none touches this path)' && ok "explain: no continuation yet" || bad "explain none" +echo '{"version":1,"dir_path":"x","history":[]}' > /dev/null +"$C" claim agent-x src a.c "explain test" >/dev/null; "$C" whisper agent-x src - "explain whisper" >/dev/null +ex=$("$C" explain src); echo "$ex" | grep -q 'held by agent-x' && echo "$ex" | grep -q 'whisper agent-x -> all: explain whisper' && ok "explain shows shared locks + whispers" || bad "explain coordination" +STORE=$(git rev-parse --absolute-git-dir)/crumb/v1; mkdir -p "$STORE/continuations" +cat > "$STORE/continuations/cc-9001-test.json" < "$STORE/continuations/cc-9002-other.json" < PASS' && ok "explain surfaces continuation whose owned_paths match" || bad "explain continuation" +echo "$ex" | grep -q 'cc-9002-other' && bad "explain ignores continuation about another path" || ok "explain ignores continuation about another path" +"$C" explain docs | grep -q 'id: cc-9002-test\|id: cc-9002-other' && ok "explain matches via coordination.scope" || bad "explain scope" +"$C" explain "$T/nonexistent" >/dev/null 2>&1; [ $? -ne 0 ] && ok "explain on missing path fails" || bad "explain missing" exit $fail ```