Skip to content

feat(meta-orchestrator): Stage 3 — delta-diff helper + reconciliation rule + paired-negative - #243

Merged
artyhoo merged 1 commit into
stagingfrom
feat/meta-orch-stage-3-delta-read
May 26, 2026
Merged

feat(meta-orchestrator): Stage 3 — delta-diff helper + reconciliation rule + paired-negative#243
artyhoo merged 1 commit into
stagingfrom
feat/meta-orch-stage-3-delta-read

Conversation

@artyhoo

@artyhoo artyhoo commented May 26, 2026

Copy link
Copy Markdown
Owner

Summary

Stage 3 of the meta-orchestrator-mode-triage-and-planner umbrella ships the read-side cohesion layer for the delta artefact persisted by Stage 2B (#240) and wired in Stage 2C (#242). Substrate stays β-2 (sibling JSON sidecar) per R-phase verdict.

What ships:

  1. helpers/delta-diff.sh (68 LOC) — deterministic positional-arg set-diff between prior .untracked_seen[].id (delta JSON) and current candidate ids; emits NEW-SINCE-LAST: <id> / RESOLVED-SINCE-LAST: <id> sorted lines. Edge cases: missing → all current = NEW; corrupt JSON → exit 1 + stderr; zero args → exit 2 + usage. MO_DELTA_FILE seam. Carries @dual-pair: meta-orchestrator-delta-diff + @cc-only-rationale.
  2. references/master-backlog-delta.md (78 LOC) — discipline reference doc mirroring plan-cache.md §1–§4 for the parallel delta artefact: §1 read-side touchpoints, §2 reconciliation rule (binding trigger = L1+L2-sweep divergence, NOT git-HEAD-SHA — counters T-Stage3-A), §3 helper-scope contract, §4 anti-patterns (#delta-as-source-of-truth, #delta-arrays-writer-creep, #delta-clobbers-mechanical-state, T-Stage3-A #cache-delta-mirror-pattern-mismatch).
  3. SKILL.md §2.5 — Step 1 inlines reconciliation pointer + T-mem-A counter; Step 8 rewritten to invoke delta-diff.sh deterministically while preserving the β-2 rationale (Direction A REJECTED per R-phase β-2); See also consolidates the cache + delta discipline references.
  4. packages/core/hooks/delta-diff.test.ts (153 LOC) — 7-case paired-negative: EMPTY-SEEN / IDENTICAL / MIXED-DIFF (label-mutation falsifier — swap of NEW/RESOLVED prefix in helper would fail per-id label assertion) / ALL-RESOLVED / SPECIAL-CHARS (real namespace shapes per priority-score.sh) / CORRUPT-JSON / BOUNDARY. 7/7 green.

Process discipline:

  • Phase -1 cold-review (Opus reviewer Agent) caught 2 BLOCKER + 3 MAJOR + 4 MINOR before dispatch; all resolved (B1 candidate-id source ambiguity → positional args; B2 Prior-art trailer obligation; M1 3-way anchor collision → separate anchor for delta-diff.sh; M2 β-2 rationale preservation; M3 T-trap enumeration).
  • update-delta.sh UNCHANGED per kickoff scope.
  • 600-line markdown cap honoured — SKILL.md compressed to exactly 600 LOC (Step 8 collapsed from !shell block to prose-with-inline-backtick after classifier blocked both cap bump in .husky/pre-commit and allowed-tools expansion in SKILL.md frontmatter).
  • Classifier-respected: zero edits to .husky/** or allowed-tools (both denied; no bypass attempted).

Binding spec compliance

§1.7 Forward-check applied

Forward — complies with which project rules:

  • build-first-reuse-default.md:50 — REUSE plan-cache.md §1–§4 structure; BUILD delta-diff.sh per R-phase Area B verdict (no upstream in-session bash multi-source-aggregator set-diff helper).
  • no-paid-llm-in-ci.md:23 — deterministic bash + jq + comm + sed; zero API-billed calls.
  • doc-authority-hierarchy.md:71 — master-backlog-delta.md carries Authoritative-for + NOT-authoritative-for header.
  • dual-implementation-discipline.md:73 — delta-diff.sh carries @dual-pair: meta-orchestrator-delta-diff + @cc-only-rationale; doc + update-delta.sh share meta-orchestrator-master-backlog-delta anchor (mirrors plan-cache.mdupdate-cache.sh precedent).
  • ai-laziness-traps.md:115 — canonical T3/T7/T11/T13/T15/T16/T19/T20 enumerated in commit body + domain-specific T-Stage3-A (#cache-delta-mirror-pattern-mismatch) codified in references/master-backlog-delta.md:55 §4.
  • reviewer-discipline.md:24 — Phase -1 reviewer findings resolved before dispatch (not auto-picked); REVISE → 2 BLOCKER + 3 MAJOR addressed.
  • parallel-subwave-isolation.md:25 — worked in isolated worktree at /Users/art/code/rules-as-tests-aif-stage-3-delta (branch off origin/staging per project_automerge_staging_plan).
  • recommendation-laziness-discipline.md:33 — all design choices cite design §7.1/§7.2 + R-phase §2 inline by file:line; no inline verdicts without evidence.
  • phase-research-coverage.md:50 — this PR-body section is the §1.7 check.
  • phase-research-coverage.md:107 §1.11 — source-of-truth verified mid-session; caught local staging 2 commits behind origin/staging before edits (would have built against stale base; corrected by branching off origin/staging directly).
  • phase-research-coverage.md:118 §1.12 — β-2 verdict committed not option-dumped (R-phase §2.5 evidence — #cache-writer-feature-creep anti-pattern at plan-cache.md:55).

§1.7 Backward-check applied

Backward — what is superseded or affected:

  • SKILL.md:159 — §2.5 Step 1 minor edit: parenthetical with reconciliation pointer added to header line (NET 0 LOC).
  • SKILL.md:225 — §2.5 Step 8 prose rewrite: was 2C 1-line prose set-diff stub; now 1-line prose with inline helper invocation + β-2 rationale preserved + paired-negative + reference doc pointers (NET 0 LOC).
  • SKILL.md:604 — See also: consolidated parallel cache + delta references into single new bullet (NET +1 LOC; total SKILL.md = exactly 600 / cap).
  • helpers/delta-diff.sh:1 NEW — 68 LOC; pure-bash + jq + comm.
  • references/master-backlog-delta.md:1 NEW — 78 LOC; mirrors plan-cache.md.
  • packages/core/hooks/delta-diff.test.ts:1 NEW — 153 LOC paired-negative; capability commit per CLAUDE.md gate (>80 LOC under packages/) → Prior-art: trailer present below.
  • helpers/update-delta.sh:1 UNCHANGED — Stage 2B writer-side contract preserved per kickoff scope.
  • references/plan-cache.md:1 UNCHANGED — precedent referenced, never modified.
  • No .claude/rules/*.md modified.
  • No .husky/* modified (classifier-protected + out of scope per kickoff «NOT scope» list — cap-bump deferred).
  • No allowed-tools frontmatter expansion (classifier-protected; Step 8 reverted to prose-with-inline-backtick to fit existing permission surface).
  • No existing packages/core/principles/*.test.ts modified.
  • Principle 18 + 19 still green (verified via pnpm -C packages/core exec vitest run principles/18-... principles/19-...; 32 tests pass).
  • File scope exactly 4 (M SKILL.md + 3 new files; verified via git diff origin/staging --name-only).
  • SSOT prior-art-evaluations.md UNCHANGED in this PR — R-phase rows docs(research): cross-worktree gitignored coord-doc sync — verdict ADAPT (symlink-to-canonical) #78fix(hooks): force visible "🟢 Простыми словами" block in end-of-turn reminder #81 ship in a separate atomic commit per feedback_no_drive_by_prs (this PR's scope = Stage 3 implementation deliverable only).

Pre-merge verification

  • delta-diff.sh smoke-tested locally (6 cases: missing file / empty seen / mixed diff / all-resolved / corrupt JSON / boundary / MO_DELTA_FILE seam) — verified: local Bash invocations
  • packages/core/hooks/delta-diff.test.ts 7/7 green — verified: pnpm exec vitest run hooks/delta-diff.test.ts
  • All 4 affected helper tests green (delta-diff + update-delta + update-cache + principles 18/19) — verified: 35 tests / 4 files green local run
  • All 19 principle tests still green (130 passed / 4 skipped) — verified: pnpm exec vitest run principles/
  • markdownlint-cli2 0 errors on SKILL.md + master-backlog-delta.md — verified: local lint run
  • scripts/check-skill-drift.sh 0 errors — verified: local run (rules-table region up-to-date)
  • SKILL.md = exactly 600 LOC (cap = 600) — verified: wc -l
  • doc-authority-hierarchy hook PASS on master-backlog-delta.md (exit 0) — verified: piped JSON probe
  • §1.7 trailer present in commit body — verified: pre-push hook accepted on retry
  • CI ci-success green on PR — owner: GitHub Actions (post-push)
  • Auto-merge into staging once ci-success green — owner: GitHub auto-merge (post-CI)

Acceptance criteria

  • SKILL.md §2.5 Step 1 carries reconciliation pointer + T-mem-A counter reference — verified: file content
  • SKILL.md §2.5 Step 8 invokes delta-diff.sh (inline backtick command, preserves β-2 rationale) — verified: file content
  • references/master-backlog-delta.md exists with §1–§5 mirroring plan-cache.md structure + binding trigger condition (L1+L2-sweep divergence) — verified: file content + grep
  • helpers/delta-diff.sh ships with deterministic set-diff semantics + 4 edge cases + MO_DELTA_FILE seam — verified: smoke tests + paired-negative
  • packages/core/hooks/delta-diff.test.ts 7 cases ≥1 label-mutation falsifier — verified: MIXED-DIFF asserts per-id label binding
  • T-Stage3-A domain-specific trap codified in references/master-backlog-delta.md §4 — verified: grep
  • update-delta.sh UNCHANGED — verified: git diff origin/staging -- helpers/update-delta.sh

Auto-merge

This PR targets staging (trunk per project_automerge_staging_plan). Auto-merge will fire on ci-success green via the repo's branch-protection configuration. No squash needed (single commit).

Follow-ups (separate atomic PRs per feedback_no_drive_by_prs)

… rule + paired-negative

Stage 3 of the meta-orchestrator-mode-triage-and-planner umbrella ships the
read-side cohesion layer for the delta artefact persisted by Stage 2B and
wired in Stage 2C: a deterministic set-diff helper (delta-diff.sh) + a
discipline reference doc (master-backlog-delta.md) + a 7-case paired-negative
test for the set-diff logic. SKILL.md §2.5 Step 8 is rewritten to invoke the
helper deterministically while preserving the β-2 rationale; Step 1 gains a
reconciliation pointer.

What ships:
- New helpers/delta-diff.sh — pure-bash + jq, positional-arg set-diff between
  prior .untracked_seen[].id (delta JSON) and current candidate ids; emits
  "NEW-SINCE-LAST: <id>" + "RESOLVED-SINCE-LAST: <id>" lines. Edge cases:
  missing file → all current = NEW; corrupt JSON → exit 1 + stderr; zero
  args → exit 2 + usage. MO_DELTA_FILE seam. Carries @dual-pair:
  meta-orchestrator-delta-diff + @cc-only-rationale (in-session CC helper).
- New references/master-backlog-delta.md (78 LOC) — mirrors plan-cache.md §1-§4
  for the parallel delta artefact: §1 read-side touchpoints, §2 reconciliation
  rule (binding trigger = L1+L2-sweep divergence, NOT git-HEAD-SHA — counters
  the cache→delta verbatim-mirror trap T-Stage3-A), §3 helper-scope contract
  (writer = metadata only; arrays = body-owned per Stage 2C), §4 anti-patterns
  (#delta-as-source-of-truth, #delta-arrays-writer-creep,
  #delta-clobbers-mechanical-state, T-Stage3-A
  #cache-delta-mirror-pattern-mismatch). Carries @dual-pair:
  meta-orchestrator-master-backlog-delta + Authoritative-for header per
  doc-authority-hierarchy.md §3.
- SKILL.md §2.5 Step 1 — inlines reconciliation pointer + T-mem-A counter
  reference to references/master-backlog-delta.md §2 (mechanical L1+L2 sweep
  wins on divergence; untracked_seen is stage-0 cache, never load-bearing).
- SKILL.md §2.5 Step 8 — replaces 2C prose with the deterministic helper
  invocation (inline backtick command, kept prose-form to fit under the
  600-line markdown cap; AI invokes via its own emitted shell block at
  runtime); preserves the β-2 rationale ("Direction A REJECTED per R-phase
  β-2") + adds set-diff semantics + paired-negative contract pointers.
- SKILL.md See also — consolidates plan-cache.md + master-backlog-delta.md
  link as parallel cache + delta discipline references.
- New packages/core/hooks/delta-diff.test.ts (153 LOC) — 7-case paired-
  negative (EMPTY-SEEN / IDENTICAL / MIXED-DIFF / ALL-RESOLVED / SPECIAL-
  CHARS / CORRUPT-JSON / BOUNDARY); label-mutation falsifier in MIXED-DIFF
  (swap of NEW/RESOLVED prefix in helper would fail per-id label assertion).

Binding spec compliance:
- design §7.1 (β-2 sibling JSON sidecar) — Stage 3 ships the read side that
  consumes the writer shipped Stage 2B (#240) + body-owned arrays shipped
  Stage 2C (#242). update-delta.sh UNCHANGED per kickoff scope.
- design §7.2 (master-plan auto-update) — NO auto-write to wave-sequencing-
  plan.md §0 (Direction A REJECTED). Maintainer manually updates §0 from
  surfaced NEW/RESOLVED-SINCE-LAST emissions.
- R-phase §2 — β-2 verdict honoured; T16 problem-class separation from
  Cline Memory Bank ADAPT pattern.
- plan-cache.md precedent (PR #236) — §1-§4 structure mirrored; trigger
  condition rebuilt from scratch per T-Stage3-A.

Phase -1 self-review (Opus reviewer Agent, cold-start) caught and forced
resolution on 2 BLOCKER + 3 MAJOR + 4 MINOR before dispatch (B1 candidate-id
source, B2 Prior-art trailer obligation, M1 3-way anchor collision, M2 β-2
rationale preservation, M3 T-trap enumeration; m1-m4 fix-in-place).

§1.7: forward-check applied — build-first-reuse-default.md:50 (REUSE plan-cache.md §1-§4 + BUILD delta-diff per R-phase Area B verdict); no-paid-llm-in-ci.md:23 (deterministic bash + jq, zero API calls); doc-authority-hierarchy.md:71 (master-backlog-delta.md carries Authoritative-for header); dual-implementation-discipline.md:73 (delta-diff.sh carries @dual-pair: meta-orchestrator-delta-diff + @cc-only-rationale; doc + writer share meta-orchestrator-master-backlog-delta anchor); ai-laziness-traps.md:115 (T3/T7/T11/T13/T15/T16/T19/T20 enumerated + domain-specific T-Stage3-A codified in references/master-backlog-delta.md:55); reviewer-discipline.md:24 (Phase -1 REVISE findings resolved before dispatch, not auto-picked); parallel-subwave-isolation.md:25 (isolated worktree at rules-as-tests-aif-stage-3-delta); recommendation-laziness-discipline.md:33 (all design choices cite design §7.1/§7.2 + R-phase §2 inline by file:line); phase-research-coverage.md:50 (this trailer = §1.7 check); phase-research-coverage.md:107 (source-of-truth verify — discovered local staging was 2 commits behind origin/staging mid-session, base corrected before edits); phase-research-coverage.md:118 (β-2 verdict committed not option-dumped). backward-check sweep — .claude/skills/meta-orchestrator/SKILL.md:159 (§2.5 Step 1 minor edit: reconciliation pointer inline); .claude/skills/meta-orchestrator/SKILL.md:225 (§2.5 Step 8 prose rewrite preserving β-2 rationale); .claude/skills/meta-orchestrator/SKILL.md:604 (See also consolidated link); .claude/skills/meta-orchestrator/helpers/delta-diff.sh:1 (new 68 LOC helper); .claude/skills/meta-orchestrator/references/master-backlog-delta.md:1 (new 78 LOC discipline doc); packages/core/hooks/delta-diff.test.ts:1 (new 153 LOC paired-negative — capability commit per CLAUDE.md gate, Prior-art trailers below); .claude/skills/meta-orchestrator/helpers/update-delta.sh:1 UNCHANGED (Stage 2B contract); .claude/skills/meta-orchestrator/references/plan-cache.md:1 UNCHANGED (precedent referenced not modified); no .claude/rules/*.md modified; no .husky/* modified (classifier-protected + out of scope per kickoff "NOT scope" list); no existing packages/core/principles/*.test.ts modified; principle 18/19 still green (verified via vitest run); file scope exactly 4 (M SKILL.md + 3 new files; verified via git diff origin/staging --name-only).

Prior-art: docs/meta-factory/research-patches/2026-05-26-meta-orchestrator-mode-triage-prior-art.md §2 (Area B BUILD verdict — β-2 sibling JSON sidecar; T16 problem-class separation from Cline Memory Bank ADAPT pattern; mirrors update-delta.sh writer-side contract shipped Stage 2B).
Prior-art: docs/meta-factory/research-patches/2026-05-25-meta-orchestrator-mode-triage-and-planner-design.md §7.1 (binding design — read-side delta diff + reconciliation pointer for §2.5 Step 8).
@artyhoo
artyhoo enabled auto-merge May 26, 2026 11:11
@artyhoo artyhoo closed this May 26, 2026
auto-merge was automatically disabled May 26, 2026 12:42

Pull request was closed

@artyhoo artyhoo reopened this May 26, 2026
@artyhoo
artyhoo enabled auto-merge May 26, 2026 12:43
@artyhoo
artyhoo merged commit c4b63ac into staging May 26, 2026
41 of 60 checks passed
artyhoo added a commit that referenced this pull request May 26, 2026
…) + parse helper + paired-negative

Stage 4 of meta-orchestrator-mode-triage-and-planner umbrella (optional per design §13).
Wires the 6 override flags referenced in SKILL.md §2.5 Step 5 predicates but never parsed.
Pure-bash parser; OVERRIDE_MODE+REASON emission; routing tree short-circuit. Anti-pattern
guard mechanism documented in references/mode-overrides.md §5 (active rate-check deferred
to follow-up — override_log[] schema field absent from current _master-backlog-delta.json
per Stage 2B/2C contract; mechanism wired only when schema extension lands).

SKILL.md wiring (Step 0 preamble + §2.5 short-circuit) deferred to follow-up after
maintainer cap-bump PR (per #243 follow-up note). Stage 4 ships A/B/C infrastructure
only; helper is fully testable in isolation. Cap blocker: SKILL.md at 600 LOC; D.1-D.3
add ~11-12 LOC; achievable compression ~8-9 LOC max (Phase -1 reviewer MAJOR-3 finding).

Prior-art: docs/meta-factory/prior-art-evaluations.md#81 (oh-my-openagent alias dispatch REFERENCE; R-phase Area C verdict 2026-05-26 BUILD for flags + REFERENCE for aif-handoff AGENT_USE_SUBAGENTS shape).
Prior-art: docs/meta-factory/research-patches/2026-05-25-meta-orchestrator-mode-triage-and-planner-design.md §10 (override-flags spec — 6 flags + reason ≥20 chars + emission contract + anti-pattern).

§1.7: forward-check applied — .claude/rules/build-first-reuse-default.md:50 (REUSE plan-cache.md:3-4 / update-delta.sh:1-40 header + seams pattern for new helper + ref doc; BUILD parse-override-flags.sh per R-phase Area C verdict — no upstream bash CLI override parser with 6-flag mutually-exclusive semantics; confirmed R-phase §3 evidence); .claude/rules/no-paid-llm-in-ci.md:23 (deterministic bash, zero API calls); .claude/rules/doc-authority-hierarchy.md:71 (references/mode-overrides.md:3-6 carries blockquote Authoritative-for header mirroring plan-cache.md:3-4 format; Class C declared line 3); .claude/rules/dual-implementation-discipline.md:73 (helpers/parse-override-flags.sh:37 carries @dual-pair: meta-orchestrator-mode-overrides + @cc-only-rationale:38; ref doc line 27 carries matching HTML comment anchor); .claude/rules/ai-laziness-traps.md:115 (T3/T7/T11/T13/T15/T16/T19/T20 + T-MO-design-A + T-Stage4-A domain-specific traps active; T19 own cold-QA: all 17 VERIFY rows run; T20 all recommendations backed by tool-call evidence); .claude/rules/reviewer-discipline.md:24 (Phase -1 cold-review 2 BLOCKER + 4 MAJOR + 5 MINOR findings resolved before dispatch; cap-blocker finding MAJOR-3 correctly handled via fallback path); .claude/rules/parallel-subwave-isolation.md:25 (CC isolation:worktree verified — worktree branch feat/meta-orchestrator-stage-4-cli-overrides from origin/staging HEAD c4b63ac); .claude/rules/phase-research-coverage.md:50 (this trailer = §1.7 check); .claude/rules/phase-research-coverage.md:107 §1.11 (base = origin/staging c4b63ac = Stage 3 merged PR #243 verified via git log). backward-check sweep — .claude/skills/meta-orchestrator/references/mode-overrides.md:1 (NEW 171 LOC Class C ref doc; blockquote header; §1-§7 sections; @dual-pair anchor line 27); .claude/skills/meta-orchestrator/helpers/parse-override-flags.sh:1 (NEW 128 LOC pure-bash helper; @dual-pair line 37; @cc-only-rationale line 38; MO_OVERRIDE_REASON_MIN seam line 42; bash 3.2 compatible — no associative arrays; case statement alias map lines ~79-87); packages/core/hooks/parse-override-flags.test.ts:1 (NEW 137 LOC paired-negative — 9 cases / 14 tests via it.each; capability commit ≥80 LOC under packages/; spawnSync shape mirrors delta-diff.test.ts:68 + update-delta.test.ts:32); .claude/skills/meta-orchestrator/SKILL.md:1 UNCHANGED (deferred pending cap-bump follow-up; D.1-D.3 edits deferred; SKILL.md stays at 600 LOC = pre-commit cap limit); .claude/skills/meta-orchestrator/helpers/update-delta.sh:1 UNCHANGED (schema unchanged; override_log[] is design-only spec in references/mode-overrides.md §5); .claude/skills/meta-orchestrator/helpers/classify-work.sh:1 UNCHANGED (DN-3 binding); .claude/skills/meta-orchestrator/helpers/update-cache.sh:1 UNCHANGED; .claude/rules/*.md UNCHANGED; .husky/* UNCHANGED (classifier-protected); allowed-tools frontmatter UNCHANGED; existing packages/core/principles/*.test.ts UNCHANGED; docs/meta-factory/prior-art-evaluations.md:1 UNCHANGED (SSOT row #81 shipped Stage 3; not touched per feedback_no_drive_by_prs).
artyhoo added a commit that referenced this pull request Aug 9, 2026
…python lane's provenance producer (#1338)

S1 shipped the per-rule lock shape and a working fragment READER; the PRODUCER
never existed for the python lane's live researched path, so every emitted rule
reads {"provenance":[],"tier":2}. Recorded as PARK-S1-7 in PR #1333 because the
fix needs packages/core/install/rule-bootstrap-cli.ts, outside S1 §2.

Un-parked by operator decision 2026-08-09 (the recorded revisit trigger — S2's
targeted staleness — had NOT fired: no S2 kickoff, branch or PR exists).

Authored as its own stage rather than folded into S2: the file sets are disjoint
(S2 owns the three deps-hash-check.sh copies), and unlike S2 this stage is
container-dispatchable because it writes nothing under .claude/**.

Beyond the two causes the park record named, §1 adds one the park did not know:
the fragment dir is SHARED across lanes and cargo/go glob it whole
(46-cargo.sh:257-268, 47-go.sh:224-232), so python fragments written naively
surface as foreign rules in their locks. Both readers are therefore in §2 and
criterion 4 gates it.

The §3 host-verify contract also closes the two gate-coverage holes S1 shipped
with: it runs packages/core/synthesizer (S1's contract never did, so it could
not see this defect class) and the synth-bundle drift check that
run-local-ci-sweep.sh omits. Verified 5/5 on Darwin.

Prior-art: skipped — kickoff markdown only, no capability introduced; the stage's own §4 routes the executor to SSOT #243 if its implementation crosses a LOC threshold.

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