Skip to content

fix(scripts): the corpus guard tests materialisation, not existence, in all three arms — a session worktree's task sync no longer deletes the farm - #511

Merged
github-actions[bot] merged 2 commits into
mainfrom
fix/empty-corpus-guard
Oct 16, 2026

Conversation

@aitrawog

@aitrawog aitrawog commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Closes #508

Summary

A guard that tests existsSync is not a guard on a system that creates empty mount points. git worktree add creates the submodule MOUNT POINT, so every session worktree — the layout AGENTS.md Part II rule 2 prescribes for every lane — has marketplace/ present and empty. The old guard accepted that as a corpus, so charly task sync derived zero skills and published the result as a state: it deleted all 353 .dsh/skills entries and rewrote reasonix.toml's [skills] paths to zero entries, reporting exit=0 done — while the harness-config gate, on the same tree, turned RED with the same derivation's false STALE verdict.

One predicate, one module, per derivation INPUT. scripts/lib/corpus.mjs owns it; the flat farm enumerates skill files and needs corpusHasSkills, while reasonix.toml enumerates family directories and needs corpusHasFamilies. A tree can hold one input without the other — the gate's own staged tree does, and this worktree does — so a guard that stopped the whole run on the first unmet need would silently drop the half that could still derive. Each half reports its own visible SKIP and the other continues, and the writer writes nothing for a skipped half rather than publishing a zero-entry result.

All three arms now agree on the same tree — the writer, --check, and the gate's two skip tests — which is what the defect was: one predicate with three implementations and only one honest. The two gate skip tests and the writer's notice import the same module and print the same reason, so they cannot paraphrase their way apart again.

How tested

The head, and one command whose output would differ if the evidence came from another tree — the message-only amend before the first push moved the head, not the tree, and two equal tree hashes cannot both be true of different content. This is the head the measurements below were taken on:

Round 1 note: the PR then went BEHIND — #509 merged to main at 13:16:18Z, so the base this branch was cut from had advanced — and it was brought current with gh pr update-branch (a MERGE, never a rebase). On the merged tree the four arms were re-run and still agree, which is the point of re-measuring rather than assuming:

$ node scripts/sync-skill-bindings.mjs --self-test | tail -1
sync-skill-bindings --self-test: 17/17 arms live and correct
$ node scripts/check-harness-config.mjs --self-test | tail -1
check-harness-config --self-test: OK (28/32 arms live — "27 mutations that must go RED + 1 corpus-absent tree that must stay GREEN"; 4 skipped — surface not materialized in this checkout)
$ node scripts/check-harness-config.mjs > /dev/null 2>&1; echo "gate rc=$?"
gate rc=0
$ node scripts/sync-skill-bindings.mjs --check > /dev/null 2>&1; echo "--check rc=$?"
--check rc=0
$ node scripts/sync-skill-bindings.mjs --only farm > /dev/null 2>&1; echo "writer rc=$?"
writer rc=0
$ echo "farm=$(ls .dsh/skills | wc -l) reasonix=$(grep -cE '^\s*"marketplace/[a-z0-9-]+/(skills|agents)",?$' reasonix.toml)"
farm=353 reasonix=43
$ git diff --quiet HEAD -- reasonix.toml && echo "reasonix.toml unmodified vs HEAD: yes"
reasonix.toml unmodified vs HEAD: yes

The merged head, after the base move — 7f06a648 carries main's #509 CHANGELOG and its six gitlinks, and touches none of this PR's four files:

$ git rev-parse HEAD HEAD^{tree}
9d66ec8c18f365dc21091b0827a1e794c247e305
7f06a6487ab8b0f4bf00ea363bd68182abf101b9
$ git rev-parse 7f06a6487ab8b0f4bf00ea363bd68182abf101b9^{tree}
7f06a6487ab8b0f4bf00ea363bd68182abf101b9
$ git log --oneline -2
9d66ec8 Merge branch 'main' into fix/empty-corpus-guard
716623b fix(scripts): the corpus guard tests MATERIALISATION, not existence, in all three arms

The first fence's head/tree pair, then, is provenance for the evidence; this one is the published head. Both are shown.

$ git rev-parse HEAD HEAD^{tree}
716623b2d5556f8e43b6478d2f7d58baf9e21e2f
e8c230dd23da5eaa4b4bc8cef921eea0b599b044
$ git rev-parse e8c230dd23da5eaa4b4bc8cef921eea0b599b044^{tree}
e8c230dd23da5eaa4b4bc8cef921eea0b599b044

Change class, read from the owner's matrix (/charly-check:check, references/beds-and-r10.md — not its SKILL.md index): a hook/workflow script change. Its pre-flight is the parse check, and its gate is "execute the changed script live: run the hook directly (paste its output)" — no bed fan-out is required for this class, and no bed can read these paths.

$ node --check scripts/sync-skill-bindings.mjs && node --check scripts/check-harness-config.mjs && node --check scripts/sync-skill-bindings.selftest.mjs
rc=0        # all three parse

The changed script, executed live, in both modes, on this tree — the writer's own destructive arm included:

$ node scripts/sync-skill-bindings.mjs --check
SKIP  marketplace/ carries no skills in /home/atrawog/Sync/Atrapub/mo/dsh/opencharly/.worktrees/umbrella-pin-sync/opencharly-derivation — the corpus is the input, and a derivation with nothing to derive from is not a state (run: git submodule update --init marketplace)
SKIP  marketplace/ carries no families in /home/atrawog/Sync/Atrapub/mo/dsh/opencharly/.worktrees/umbrella-pin-sync/opencharly-derivation — the corpus is the input, and a derivation with nothing to derive from is not a state (run: git submodule update --init marketplace)
sync-skill-bindings: opencode.json skills.paths  unchanged (names the corpus root)
sync-skill-bindings: clean
rc=0
$ node scripts/sync-skill-bindings.mjs --only farm          # the WRITER, the destructive arm
SKIP  marketplace/ carries no skills in /home/atrawog/Sync/Atrapub/mo/dsh/opencharly/.worktrees/umbrella-pin-sync/opencharly-derivation — the corpus is the input, and a derivation with nothing to derive from is not a state (run: git submodule update --init marketplace)
sync-skill-bindings: done
rc=0
$ ls .dsh/skills | wc -l ; grep -cE "^\\s*\"marketplace/[a-z0-9-]+/(skills|agents)\",?$" reasonix.toml
353
43

353 and 43 after the writer ran: the farm was not emptied and the reasonix list was not rewritten. That pair is the defect, gone.

The coverage that was missing ships with it, and it fails without the change. Two fixtures are new: an empty corpus, and the shape this environment actually has — family directories present, skill files absent (the gate's own staged tree, which stages 43 family dirs from reasonix.toml's list and zero SKILL.md files). Run against the old scripts, the new suite goes RED:

$ node <old-sync-skill-bindings.mjs> --self-test      # old scripts, NEW selftest
FAIL  corpus absent: --only reasonix SKIPS VISIBLY rather than crashing, and agrees with the gate
FAIL  corpus absent: --only farm SKIPS VISIBLY rather than crashing, and agrees with the gate
FAIL  corpus present but EMPTY: the writer SKIPS visibly and writes NOTHING, and --check agrees
FAIL  family dirs but NO skill files: the farm half SKIPS and deletes nothing, the reasonix half still derives
FAIL  this checkout: the derivation is already a fixed point
sync-skill-bindings --self-test: 12/16 arms live and correct
rc=1

$ node scripts/sync-skill-bindings.mjs --self-test     # fixed tree
sync-skill-bindings --self-test: 17/17 arms live and correct
rc=0

Five arms discriminate. And the gate's own self-test — the step that was RED on #509 — is green again, with both corpus shapes covered:

$ node scripts/check-harness-config.mjs --self-test
  PASS  check 8/13: a tree whose corpus is absent SKIPS both derivation arms visibly and stays green
  PASS  check 8/13: a tree whose corpus is present-but-empty SKIPS both derivation arms visibly and stays green
check-harness-config --self-test: OK (28/32 arms live — "27 mutations that must go RED + 1 corpus-absent tree that must stay GREEN"; 4 skipped — surface not materialized in this checkout)
rc=0

And the gate itself, on this corpus-less tree, is GREEN where it was RED — this is the outcome the fix exists for:

$ node scripts/check-harness-config.mjs
  PASS  marketplace/ carries no families in <wt> — the corpus is the input, and a derivation with nothing to derive from is not a state (run: git submodule update --init marketplace) — [skills] paths derivation check skipped (structural assertions above still hold)
  PASS  marketplace/ carries no skills in <wt> — the corpus is the input, and a derivation with nothing to derive from is not a state (run: git submodule update --init marketplace) — the .dsh/skills derivation check skipped (the shape arm above still holds)
check-harness-config: OK
rc=0

The committed tree, through the umbrella's own battery (which the pre-commit hook ran on this commit): task pin-check: [pass] the pin check holds; task self-test: [pass]; every scripts/check-*.mjs arm OK; pre-commit: OK — with the corpus-dependent arms reporting visible SKIPs rather than failing, which is the behaviour this change restores.

Change classification

  • Change class: script — scripts/lib/corpus.mjs (new, 70 lines), scripts/sync-skill-bindings.mjs, scripts/check-harness-config.mjs, scripts/sync-skill-bindings.selftest.mjs; 4 files, +195/−40.
  • Verification gate: the class's own — parse, then execute the changed script live in both modes (pasted above), plus its self-test and the gate's self-test, both of which gained the arm that fails without the change; and the umbrella's committed battery on the final tree.
  • Attribution tier: fully tested and validated — the class's gate passed on the committed tree, the changed paths executed live with retained output, and the new coverage was shown to discriminate (12/16 against the old scripts, 17/17 here).
  • Behaviour change, stated: a non-materialised corpus now SKIPS where the derivation previously FAILED (exit 1) for the absent case. That is deliberate and is the "all three arms agree" requirement: the gate SKIPS on such a tree, so a writer that failed there would put the two arms back into disagreement. The anti-crash property the old arm asserted is unchanged, and the arm now says so in its own name.
  • Breaking change + rollback: none; a revert restores the previous guard.

Rulebook compliance

  • R0 — /charly-internals:git-workflow, /charly-check:check and its owner's matrix file, /charly-internals:skills, /charly-internals:agents (the derived-binding doctrine this repairs).
  • R1 — the defect, its mechanism, its missed control and its blast radius are in the issue, and this PR fixes it. One anomaly was met during the fix and is reported rather than smoothed: the first version of the guard used a single predicate for both derivations, which made the gate's staged-tree arm go RED for a different reason — so the predicate became per input, and the shape that exposed it is now an arm.
  • R2 — one predicate, in one module, imported by all three arms. The duplication this removes is the defect: the same question answered three ways, one of them wrong.
  • R3 — no workaround: no --no-verify, no bypass, no hand-edited artifact. The commit was initially refused because the hook could not load the project without charly/; the answer was to initialize the two import submodules so the gate could run, not to skip it.
  • R4 — the code is fixed; the issue text says what the code now does.
  • R5 — the superseded guard is deleted (corpusIsMaterialised, the local familiesOf, the early-exiting skip()), proven by the claim-keyed grep itself, run on the committed tree:
$ grep -rn "corpusIsMaterialised\|familiesOf\|function skip(" scripts/
rc=1
  • R6 — git status was clean before the commit and at the head; no force-push, no bypass, no direct-main push; the work is in a dedicated single-owned worktree.
  • R7 — the coverage fails without the change, pasted: five arms, 12/16 → 17/17.
  • R8 — nothing mocked; no live-service boundary in this change.
  • R9 — stated rather than hidden: this worktree has no binary of its own, and the pre-commit hook printed its own NOTICE that it used the main clone's binary. The changed paths are scripts, not Go, and the build was out of this change's scope; the substitution is disclosed here and in the hook's output rather than passed off as worktree-local.
  • R10 — the class's gate, by name, on the committed trees 716623b and, after the BEHIND update, 9d66ec8: the changed script executed live in both modes, its self-test 17/17, the gate's self-test OK, the gate itself GREEN with visible skips, and the umbrella's battery pre-commit: OK.
  • HC — one coherent cutover: the predicate, its three consumers, and the coverage that proves them land together, with no deferred half inside the scope.
  • Part II chore: sync dotgithub pin to main #5 — this is the derived-binding doctrine enforced rather than restated: a derived binding must not be able to write a zero-entry corpus as if it were a state.

Filed issues

  • opencharly/opencharly#508 — this row (Closes), carrying the mechanism, the three-arm table, the 43-vs-45 record correction, and the RCA. The fix is here rather than filed because the writer could destroy a session's tree in one command; the harness-binding half's separation argument does not apply to a defect whose blast radius is every lane's task sync.
  • Referenced, still open: opencharly#510 (the 15 unjudged pin rows of the consumer wave — differs is not behind), charly#958, plugin-check#121, opencharly#506.

What I could not do

  • No worktree-local R9 build, stated plainly: the changed paths are scripts/*.mjs, the class requires no Go gate, and the pre-commit hook recorded that it fell back to the main clone's binary. I did not build a charly binary to make the notice disappear, because that would have been ceremony for a script change — and the hook's NOTICE is the disclosure the rulebook asks for.
  • Four gate arms remain skipped in this checkout because their surfaces are not materialised here (marketplace/DISPATCHER.md, and the corpus-derived arms); the self-test names each skip rather than counting it as a pass.
  • The 15 unjudged pin rows of #510 are untouched by this PR by design: this change fixes the guard, not the pins.

Agent: umbrella-pin-sync

Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated)

atrawog and others added 2 commits October 16, 2026 15:31
…in all three arms

A session worktree — the layout AGENTS.md Part II rule 2 prescribes for every lane — has
`marketplace/` PRESENT and EMPTY, because `git worktree add` creates the submodule mount
point. `existsSync` accepted that as a corpus, so `charly task sync` derived ZERO skills and
published the result as a state: it deleted all 353 `.dsh/skills` entries and rewrote
reasonix.toml's [skills] paths to zero entries, reporting `exit=0 done` — and on the same tree
the harness-config gate turned RED with the same derivation's false STALE verdict
(#508).

One predicate, in one module (`scripts/lib/corpus.mjs`), per DERIVATION INPUT: the flat farm
enumerates skill FILES and needs `corpusHasSkills`; reasonix enumerates family DIRECTORIES and
needs `corpusHasFamilies`. A guard that stopped the whole run on the first unmet need would
silently drop the half that could still derive, so each half reports its own visible SKIP and
the other continues — and the writer writes NOTHING for a skipped half rather than publishing
a zero-entry result. All three arms now agree on the same tree: the writer, `--check`, and the
gate's two skip tests, which is the defect this removes (one predicate with three
implementations and only one honest).

The coverage that was missing ships with it: an EMPTY corpus, and the shape this environment
actually has (family directories present, skill files absent — the gate's own staged tree).
Five arms go RED without the fix, measured by running the new selftest against the old
scripts: 12/16 there, 17/17 here.

Closes #508

Agent: umbrella-pin-sync

Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated)
@github-actions

Copy link
Copy Markdown
Contributor

Review — PASS

Head SHA: 9d66ec8c18f365dc21091b0827a1e794c247e305 (branch: fix/empty-corpus-guard)

Security screen: PASS — no secrets/egress/obfuscation, no new deps, no weakened guardrail (the change strengthens the corpus guard and lands from maintainer account @aitrawog; T4 not triggered).

Checklist: All applicable rules PASS or NA.

  • A1: body supplies Summary / How-tested (with pasted output) / Attribution / rule-compliance / ## Filed issues, and ends with the italicized Assisted-by: line last.
  • A2/A3/R10: classified as hook/workflow script change; class gate (parse + execute-changed-script-live, both modes) pasted; fully tested and validated is not inflated (changed paths executed live; new arms discriminate 12/16→17/17). Numeric accounting is internally consistent (+25+70+32+68 = 195; −14+0+21+5 = 40).
  • R1–R9, HC, PIL/ADE/SDD, ARCH, DISP, COORD: NA or PASS — one shared predicate in scripts/lib/corpus.mjs, all three consumers import it; no duplication/workaround/mock; R9 disclosure honest; placement (repo tooling, not core/sdk/candy) CORRECT.

Tool-limited dispositions (unverifiable read-only, cross-checked for internal consistency — no contradiction found): the R10 bed-class matrix citation, the deepseek-v4.1-flash model name, and the 12/16 old-script RED run. No comments in the thread (0) to disposition.

Verdict: PASS


ollama-cloud/deepseek-v4.1-flash — action-review.

View action run

@github-actions
github-actions Bot enabled auto-merge (squash) October 16, 2026 13:38
@github-actions
github-actions Bot merged commit d1d9d2f into main Oct 16, 2026
1 check passed
charly-auto-merge Bot added a commit that referenced this pull request Oct 16, 2026
github-actions Bot pushed a commit that referenced this pull request Oct 20, 2026
…s) (#536)

The umbrella records the wave's merged, tagged producers:

- charly v2026.293.1537 — the plugin-check adoption (the build-step idle window)
- plugin-check v0.2026293.1223 — the fix itself
- layer-crabbox v2026.293.1244, layer-strata v2026.293.1253,
  plugin-strata v2026.293.1316, layer-openclaw v2026.293.1422 — the #511 sources
- marketplace v2026.293.1347 — the regenerated corpus (openclaw-cmd, the rows)
- distro-cachyos — the derived edge at charly's box/cachyos (the distro consumer
  merge, distro-cachyos v2026.293.1303)

Two submodules (sdk, plugin-crabbox) roll to their default-branch HEAD as the
sync advances every initialized pin — the umbrella keeping its view current, and
both are already-merged org work.

The derived harness bindings follow the corpus: the openclaw rename
(openclaw-cmd) and the strata / strata-cli / strata-layer / crabbox-cli rows
appear as .dsh/skills entries, alongside two other corpus skills the current
pin carries (fireactions, githubrunner-ubuntu).

Gate: charly task verify rc=0 on this tree with the rebuilt binary
2026.293.1538.

Agent: dsh-crabbox-079
Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated)

Co-authored-by: aitrawog <[email protected]>
@aitrawog
aitrawog deleted the fix/empty-corpus-guard branch November 1, 2026 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants