feat(zcode-parity): S7B — extend inject-subagent-context for full SubagentStart parity - #1047
Merged
artyhoo merged 1 commit intoJul 19, 2026
Conversation
…agentStart parity Replaces the framework-heredoc digest source (inject-session-bootstrap.sh) with direct extraction of the <!-- digest:start -->…<!-- digest:end --> block from .claude/session-bootstrap.md, matching inject-project-digest.sh's SubagentStart arm payload. Closes doctrine §3 Stage 7B (Wave B). Before: on ZCode, when a subagent was dispatched, its PreToolUse:Agent hook injected a hardcoded summary of THIS FRAMEWORK's goals into the subagent's prompt — even on consumer repos where that text is irrelevant. Meanwhile on CC, the SubagentStart arm of inject-project-digest.sh extracted the consumer's own digest block from .claude/session-bootstrap.md and delivered that. The two harnesses were delivering different content for the same conceptual role. After: on ZCode, the subagent-context hook now extracts the same <!-- digest:start -->…<!-- digest:end --> block from .claude/session-bootstrap.md, delivering payload parity with CC's SubagentStart arm. Plugin twin hand-mirrored (manual mode in the generator, confirmed no auto-regen). hook-paths.test.sh shows no regression (PASS=49 FAIL=12 — identical to pre-change baseline; pre-existing failures on other hooks untouched by this scope). Implementation notes: - REPO_ROOT resolution uses B1 env-first form (mirrors inject-project-digest.sh:28) so the hook stays correct under both .claude/hooks/depth-2 install and plugin-twin payload paths. - Optional tests/plugin/inject-subagent-context.test.sh does not exist on this branch — Task 4 skipped per plan. - Reclassification flag: post-change the twin starts reading repo files (session-bootstrap.md). hook-paths.test.sh:129 lists it in the "Non-sweep twins" / CAT-B sibling-source skip list, so check (h) does not currently apply. Strict reclassification would put it in-sweep, but the test is out-of-scope per kickoff §5 — flagged for follow-up. Prior-art: prior-art-evaluations.md — zcode-parity umbrella (decisions.md §Wave B Stage 7B, ADOPT-7B verdict).
This was referenced Jul 20, 2026
artyhoo
pushed a commit
that referenced
this pull request
Jul 21, 2026
…isting blocker) inject-subagent-context.test.ts shipped RED by #1047 and never passed on staging (merged past — Principles job is non-blocking). Its 5 zcode-branch tests called the hook with ZCODE_PROJECT_DIR set (for the _is_zcode gate) but relied on the REAL repo's .claude/session-bootstrap.md carrying a `<!-- digest:start/end -->` block — which it does not, by design: the framework's main-session digest is emitted dynamically by inject-session-bootstrap.sh's heredoc, never cached as a static block (a static copy would drift from the heredoc's dynamic AIF_HOOK_LANG line). So the hook correctly no-ops (empty stdout) → JSON.parse throws. Fix mirrors the sibling inject-project-digest.test.ts (which is hermetic): build a temp fixture repo whose session-bootstrap.md carries a digest block seeded with inject-session-bootstrap.sh's own output, and point the hook at it via CLAUDE_PROJECT_DIR (the root the hook reads at :44). The SSOT/no-drift assertion stays meaningful (verifies the hook reads + appends the block verbatim). Test-only change; the hook and the maintainer-owned session-bootstrap.md are untouched. Verified: test:hooks 825/826 pass (the remaining 1 = harness-config-drift, a distinct zcode-parity SSOT-drift bug from #1036/#1046 filed as #1053 — needs a domain decision, not a blind regen). Prior-art: skipped — test hermeticity fix for an existing hook, no new capability.
artyhoo
added a commit
that referenced
this pull request
Jul 21, 2026
…inciples + rule-index + install-sh + hooks + synth-bundle) (#1051) * fix(gates): restore green principles + rule-index on staging (3 pre-existing blockers) `staging` HEAD failed three push gates independently of any in-flight branch, blocking every `git push` in the repo: 1. principle 11 F1 — `.claude/rules/zcode-parity-doctrine.md` (#1045) landed with neither a `Prior-art:` trailer nor a verbatim-path SSOT citation. Closed with SSOT row #220 (the only reachable closure form once the adding commit merged; direct precedent #211 after PR #907). The doctrine file is left BYTE-IDENTICAL to staging — editing it would drag its pre-existing gitignored-plan link (.ai-factory/plans/, not in git) into lychee's changed-file scan. 2. `render-rule-index --check` — the doctrine's 312-char `Fires:` row pushed the index to 3357B over a 3072B ceiling that was ALREADY 99% consumed (3044/3072) before it landed, i.e. structurally unmeetable rather than violated. Raised INDEX_MAX_BYTES 3KB->4KB (3357 < 4096) with the reasoning recorded at the constant; index + AGENTS.md region regenerated, doctrine row unchanged. 3. principle 13 — `2026-07-18-universal-skill-stack-driven-prep.md` (#1048) landed with no §1.7 self-review section. Appended §10 as a self-review of the patch as merged (findings untouched). Verified: `npm --prefix packages/core run test:principles` 311/311 pass, `test:backends` 191/191 pass, `render-rule-index --check` exit 0. Prior-art: prior-art-evaluations.md#220 (REFERENCE — own-stack gate maintenance; F1 accepts only trailer-on-adding-commit or verbatim-path SSOT row, and the adding commits are already merged). * fix(gates): regenerate install-sh baselines drifted by #1043 (4th pre-existing blocker) PR #1043 (S6 2B-standardize, 2026-07-19) rewrote three hooks — inject-matching-rule.sh, inject-output-language.sh, inject-project-digest.sh (env-first REPO_ROOT standardization) — but did NOT regenerate the byte-identical install-sh baseline fingerprints. Proof: on origin/staging the source hook inject-matching-rule.sh hashes to 8edd7f… while every baseline fingerprint still records the pre-#1043 e1f96e… (baselines last updated by #1031, 2026-07-18, one day BEFORE #1043). The install-sh battery is pull_request-gated (audit-self.yml :622 if github.event_name == 'pull_request'), so pushes to staging never ran it and the drift sat latent; every PR since #1043 inherits the red. SNAPSHOT_MODE=capture regenerated all 8 npm baselines; diff is EXACTLY the 3 hook hashes (verified: no other file changed, new hashes match the real hook files). `SNAPSHOT_MODE=compare` → 11/11 byte-identical. Prior-art: skipped — test-fixture baseline regen after an upstream hook edit (#1043), no new capability. * fix(gates): make inject-subagent-context.test.ts hermetic (5th pre-existing blocker) inject-subagent-context.test.ts shipped RED by #1047 and never passed on staging (merged past — Principles job is non-blocking). Its 5 zcode-branch tests called the hook with ZCODE_PROJECT_DIR set (for the _is_zcode gate) but relied on the REAL repo's .claude/session-bootstrap.md carrying a `<!-- digest:start/end -->` block — which it does not, by design: the framework's main-session digest is emitted dynamically by inject-session-bootstrap.sh's heredoc, never cached as a static block (a static copy would drift from the heredoc's dynamic AIF_HOOK_LANG line). So the hook correctly no-ops (empty stdout) → JSON.parse throws. Fix mirrors the sibling inject-project-digest.test.ts (which is hermetic): build a temp fixture repo whose session-bootstrap.md carries a digest block seeded with inject-session-bootstrap.sh's own output, and point the hook at it via CLAUDE_PROJECT_DIR (the root the hook reads at :44). The SSOT/no-drift assertion stays meaningful (verifies the hook reads + appends the block verbatim). Test-only change; the hook and the maintainer-owned session-bootstrap.md are untouched. Verified: test:hooks 825/826 pass (the remaining 1 = harness-config-drift, a distinct zcode-parity SSOT-drift bug from #1036/#1046 filed as #1053 — needs a domain decision, not a blind regen). Prior-art: skipped — test hermeticity fix for an existing hook, no new capability. * fix(gates): register plugin twins in PLUGIN_INTERNAL_HOOKS SSOT (6th pre-existing blocker) harness-config-drift.test.ts failed on staging (render --check exit 1) — the LAST pre-existing Principles-job red. Root cause: #1036 (inject-project-digest, inject-output-language) and #1046 (warn-subagent-report-zcode) hand-added their plugin-channel entries directly to the GENERATED plugin/hooks/hooks.json but never registered them in PLUGIN_INTERNAL_HOOKS — the renderer's SSOT for plugin-only hooks that have no framework-model counterpart. So `render --write` removed them (43-line drift) and `--check` reported it. These three are genuinely plugin-only: absent from .claude/settings.json AND from harness-model.json, each with a real plugin/hooks/ sibling script, reaching ZCode consumers ONLY via the plugin channel. Regenerating them away would revert shipped #1036/#1046 functionality; the SubagentStart arm is also inexpressible from the model (event ∉ ZCODE_EVENTS). PLUGIN_INTERNAL_HOOKS is exactly their intended home. Changes: - render-harness-config.mjs: register the 4 twin entries in PLUGIN_INTERNAL_HOOKS (UserPromptSubmit ×2, SubagentStart, PostToolUse, Stop). PLUGIN_INTERNAL_HOOKS / PLUGIN_INCOMPATIBLE stay module-private (no export) — the drift test no longer imports them (see below). - harness-config-drift.test.ts: rewrite the N6 plugin-coverage assertion from count-equality (which only held before the twins landed, and would have required importing the registries from the untyped .mjs — breaking `tsc --noEmit` with TS7016, no declaration file) to coverage-BY-NAME: for every zcode-supported event, each model-derived hook — except the maintainer-only PLUGIN_INCOMPATIBLE set (link-coordination) — must appear by dispatch name in the plugin output. Extra plugin-internal twins are allowed; the drift gate (test above) already asserts their presence + byte-reproducibility. - plugin/hooks/hooks.json: regenerated (twins preserved; same-event ordering now internal-first — cosmetic for independent context/advisory hooks). settings.json / .mcp.json / zcode.json UNTOUCHED (model unchanged). Closes #1053. Verified: tsc --noEmit clean, test:hooks 826/826, test:principles 311/311, render-harness-config --check exit 0. Prior-art: skipped — SSOT-registration fix for existing shipped hooks, no new capability. * fix(gates): regenerate stale synth-bundle for semver 7.8.5 (7th pre-existing blocker) The committed packages/core/install/synth-and-wire.bundle.mjs was built with an older semver (pre-7.8.x — lacks functions/truncate.js + the isPrereleaseIdentifier helper). CI's synth-bundle drift gate (#755) rebuilds with the semver that root `npm install` pins per the ROOT package-lock (packages/core/node_modules/semver = 7.8.5): audit-self.yml runs the root `npm install` step ("hoists tsx to root for the hooks-suite gate") BEFORE the synth-bundle gate, so the gate builds against 7.8.5 — not the 7.8.1 that the earlier `npm ci --prefix packages/core` installs. A fresh 7.8.5 build differs from the stale committed bundle → DRIFT. Why this was masked until now: the Principles job runs principles-meta-tests FIRST, and that step has been red on staging since 2026-07-18 (the principle-11/13 blockers this PR's 4e1f6d4 fixes), which short-circuits the job before the synth-bundle step ever runs. Once the earlier blockers go green the job reaches the synth-bundle gate and the pre-existing staleness surfaces — a hidden-behind-a-red-gate regression, not introduced by any commit in this PR. Fix: rebuild with CI-parity node_modules — replicated audit-self's install sequence (`npm ci --prefix packages/core` then root `npm install` → packages/core semver 7.8.5), then committed the result. The build-synth-bundle.sh:50 path-normalization is untouched; only the bundled semver library content differs (+72/-8). Verified: `NODE_ENV=development bash scripts/build-synth-bundle.sh --check` exit 0; test:hooks 826/826; test:principles 311/311 — all green in the same node_modules state. Prior-art: skipped — snapshot regeneration of a generated artifact, no new capability. --------- Co-authored-by: t <t@t.co>
artyhoo
added a commit
that referenced
this pull request
Jul 25, 2026
…g" doc claims (#1151) Tier-1 (bulky-simple) kickoff for a bounded mechanical sweep: every claim in CLAUDE.md + .claude/rules/*.md asserting that something is "not yet landed" is verified against origin/staging and either corrected or kept with its proof. Two anchors are pre-proven stale by command in §2: - CLAUDE.md:132 says AifHandoffBackend._resolveProfileId has "no exact-match priority"; staging's AifHandoffBackend.ts:137-141 has exactly that. - zcode-parity-doctrine.md §3 marks Wave B stages 5/6/7B/9C "impl pending"; all four merged (#1046/#1043/#1047/#1044). The renderer-side D3 declaration sync is a named park trigger (§5), not scope. Prior-art: skipped — dispatch-input document only, no new capability: adds no dependency and no code module; the sweep it scopes edits existing docs. Co-authored-by: Test <test@example.com>
10 tasks
artyhoo
added a commit
that referenced
this pull request
Jul 25, 2026
…rule + zcode Wave B cascade (stale-pending-claims) (#1156) * docs(rules): truth-sweep stale «pending» claims (Anchor A + Wave B merged) Mechanical truth-sweep over the bounded §1 population defined in the kickoff grep — every «pending» / «not yet» / «impl pending» claim in CLAUDE.md + .claude/rules/*.md re-verified live against origin/staging `fab189d09e`. 5 files, 14 adjudicated hits: 11 STALE (corrected), 3 STILL-TRUE (left + inline evidence). Anchor A — CLAUDE.md:132: the «Marker value rule» paragraph misdescribed the AifHandoffBackend resolver as «no exact-match priority». Verified false: AifHandoffBackend.ts:137-141 carries the exact-name short-circuit that landed to save the Z.AI GLM-5.2 / Z.AI GLM-5.2 SDK prefix case. Corrected (a) mechanism description, (b) line anchor :131 → :137-141, (c) «only channel» → two channels (runtime short-circuit + authoring rule as belt-and-braces). Binding advice kept. Anchor B — zcode-parity-doctrine.md: Wave B Stages 5/6/7B/9C (#1043/#1044/#1046/#1047) ARE merged; the doctrine's §3 status column, §4 rationales, and §7 self-reflexive note still claimed «Decided; impl pending». Flipped past-tense; re-counted §5 ZCode tier (13→16 framework hook twins — Stage 6 added 3); §2 census rows 3/12 (plugin-gap → parity, both plugin twins shipped via Stage 6) and 19 (cc-only → parity via 4D hybrid) updated with rollup. PARK-1 honoured: scripts/render-harness-config.mjs left untouched (out of scope); the doc is honest about the *outstanding* runtime loud-declaration sync. memory-codification.md §4(0): «PENDING settings.json WIRING» → WIRED (.claude/settings.json:168 verified live; park-2 condition not met). autonomous-loop-continuity.md + destination-environment-verification.md: H11 (idle watchdog) + H12 (branch→umbrella gate) STILL-TRUE — added inline grep evidence on origin/staging `fab189d09e`. Acceptance: principle 09 (44 tests) + principle 12 (44 tests) green; rule-index check clean (no header changes); all 5 files ≤600 lines; T-SPC-B post-edit cascade sweep on zcode-parity-doctrine.md clean. Cursor :97 «live end-to-end testing is a follow-up» STILL-TRUE (no live-test commits in `git log origin/staging`). §1.7 forward+backward applied in PR body. Per-hit table there. * docs(rules): fix §4(0) contradiction — CTX Stage 1 IS activated (rework) Rework iteration 2 finding [d7b1cd54dfbb]: line 47 of memory-codification.md read "shipped but pending activation" while line 49 (edited in the prior commit) read "WIRED" + "live" — a self-contradiction introduced by this PR's own edit two lines apart. Verified the hook IS wired: jq '.hooks.PostToolUse[7]' .claude/settings.json → { matcher:"Write", command:"bash … inject-memory-codification.sh" } Updated line 47: "shipped but pending activation" → "shipped and activated". Single-line, in-place; no other changes. §4 acceptance gates re-run green: - wc -l .claude/rules/memory-codification.md → 96 (≤600) - npx tsx scripts/render-rule-index.mjs --check → up-to-date - npx vitest run packages/core/principles/09-doc-authority-hierarchy.test.ts → 37/37 pass - npx vitest run packages/core/principles/12-ai-laziness-traps.test.ts → 7/7 pass * docs(rules): revert row-3 parity flip — Stage 6 shipped row 4 twin, not row 3 (rework round 2) Rework round-1 content: row 3 (`check-doc-authority-header`) reverted to `plugin-gap` after cold-audit found Stage 6 shipped row 4's `check-doc-authority` twin, NOT row 3's. Rollup counts accordingly (parity strict 12→11, plugin-gap 0→1). §4 split into «Row 12 closed» + «Row 3 STAYS» with the live grep evidence. Cursor tier row augmented with the live proving commands (ls + grep exit 2 / 0). Dangling `(PARK-1)` references removed from §3 note and §4 Row 19 — the anchor was undefined; prose reads cleanly without it. Round-1 rework content reviewed ACCEPTED (iter-4 / iter-3 reviewers); this commit just lands it on the branch (harvest of HEAD would otherwise drop it). * docs(rules): un-dangle the §6 plan pointer — gitignored path, never tracked (lychee, harvest-fix) Pre-existing on staging (not introduced by the sweep): §6 linked .ai-factory/plans/zcode-parity-s10-doctrine-doc.md, a gitignored local plan absent from every checkout. Same defect class as the sweep's population — a doc pointing at a non-existent artifact. Restated the rationale inline, kept the path as a code span (not a link). Prior-art: skipped — one-line doc link fix, no new capability --------- Co-authored-by: Test <test@example.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
§1.7 Forward-check applied
§1.7 Backward-check applied