Skip to content

feat(zcode-parity): S6 — 2B-standardize + twin generator - #1043

Merged
artyhoo merged 1 commit into
stagingfrom
feature/zcode-parity-s6-twin-generator-0b38e6
Jul 19, 2026
Merged

feat(zcode-parity): S6 — 2B-standardize + twin generator#1043
artyhoo merged 1 commit into
stagingfrom
feature/zcode-parity-s6-twin-generator-0b38e6

Conversation

@artyhoo

@artyhoo artyhoo commented Jul 19, 2026

Copy link
Copy Markdown
Owner

§1.7 Skipped: purely mechanical standardization per decisions.md Fork 4. Rationale ≥60 chars: env-first REPO_ROOT form applied universally; generator is bash + existing patterns; no rule interaction surface.

…lly) + generator + pre-commit + twin-generation test

Source-side standardization: 10 hook source files migrated to env-first
REPO_ROOT form universally. Plugin twins regenerated (now byte-identical
or 1-line transform per inject-subagent-context marker).

Generator: scripts/generate-plugin-twins.sh (~30 LOC bash) reads source,
applies per-hook transform marker if present, writes twin.

Pre-commit: .husky/pre-commit extended to auto-regenerate twins on source change.

Test: tests/plugin/twin-generation.test.sh verifies twin = source OR matches
declared transform output.
@artyhoo
artyhoo merged commit e6d6257 into staging Jul 19, 2026
artyhoo pushed a commit that referenced this pull request Jul 20, 2026
…-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.
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>
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant