Skip to content

refactor(audit-ai-docs): DI execSync for warm-path probeR4 tests + testTimeout 120s ceiling - #233

Merged
artyhoo merged 1 commit into
stagingfrom
refactor/slow-test-triage-iphase-dn1c
May 25, 2026
Merged

refactor(audit-ai-docs): DI execSync for warm-path probeR4 tests + testTimeout 120s ceiling#233
artyhoo merged 1 commit into
stagingfrom
refactor/slow-test-triage-iphase-dn1c

Conversation

@artyhoo

@artyhoo artyhoo commented May 25, 2026

Copy link
Copy Markdown
Owner

Summary

Implements DN-1 Path C + DN-3 Option A from the slow-test-triage umbrella (R-phase patch §2-§3 + §6, merged via #231).

The 3 probeR4 tests under audit-self/audit-ai-docs.test.ts previously each spent ~24s on cold-cache npx --no-install tsx resolution (3 × 24s = 72s — sufficient to time out under the prior 36s ceiling). After this refactor:

  • 2 warm-path tests (hasTsconfig && !hasTsMorph, hasTsMorph present) use a fast execSync stub → 1-2ms warm-cache (measured twice).
  • The :344 contract test (tsconfig.json exists but ts-morph missing) keeps real execSync via bare probeR4(dir)~1.3s warm-cache, ~24s cold-cache. Semantic preservation of the real-subprocess contract is the design intent of Option C over Options A/B (R-phase §3).
  • Root vitest.config.ts gains a testTimeout ceiling comment at 120_000ms (DN-3 Option A) — future bumps must fix the slow path, not raise the lid.

Changes (3 files)

File Change
packages/core/audit-self/audit-ai-docs.ts probeR4(cwd, opts?: { execSync?: typeof execSync }) — DI seam; defaults to real execSync. Both call sites (npx --version, npx --no-install tsx ...) threaded through exec alias.
packages/core/audit-self/audit-ai-docs.test.ts Module-level fastExecSyncStub helper; 2 warm-path tests pass it to probeR4; :344 contract test unchanged (bare probeR4(dir)).
vitest.config.ts 2-line ceiling comment (no behavioural change).

Test plan (T3 — measured warm-cache durations TWICE)

npx vitest run packages/core/audit-self/audit-ai-docs.test.ts --reporter=verbose

Test Run 1 Run 2 Pre-change (cold) Path
hasTsconfig && !hasTsMorph: does NOT warn-skip 1ms 1ms ~24s cold stubbed
hasTsMorph present: does NOT warn-skip either 2ms 1ms ~24s cold stubbed
WARN(skip): tsconfig.json exists but ts-morph missing → still skips OR proceeds (:344) 1366ms 1363ms ~24s cold real execSync preserved

Stubbed tests drop to <50ms (target: <50ms each — met). Contract test stays at expected ~1.3s warm; cold-cache for :344 is ~24s (R-phase §2 measurement) — with the 60s ceiling and only 1 remaining real-subprocess test (vs prior 3 × 24s = 72s), margin is comfortable.

  • npx vitest run packages/core/audit-self/audit-ai-docs.test.ts191/191 pass (verified twice)
  • T7 adversarial grepgrep -n 'execSync(' packages/core/audit-self/audit-ai-docs.ts returns 0 matches; all call sites flow through exec alias (verified)
  • :344 contract test calls probeR4(dir) bare — no opts.execSync (verified by reading test body line 371)
  • T15 self-applicationfastExecSyncStub is a pure function, no execSync/exec/spawn inside the stub itself (the fix does not introduce a new slow test)
  • testTimeout: 60_000 unchanged in vitest.config.ts; ceiling is a documentation comment only — no behavioural bump (T-SlowTestTriage-I respected)
  • Pre-push hook PASS — principle tests 115/115, skill-drift PASS, audit-ai-docs.test.ts 191/191 (push succeeded)
  • Phase -1 cold-review per meta-kickoff §7 — fires from a separate session before merge (maintainer / dispatched cold-reviewer)

§1.7 Skipped

Localised refactor of audit-ai-docs.ts + its test + 1-line vitest.config.ts policy comment. No .claude/rules/, no packages/core/principles/, no CLAUDE.md, no template, no agent — no discipline-rule surface to forward/backward-check against. Per meta-kickoff §4b path-scope analysis: Path C does NOT match the §4b discipline-file path list (.claude/rules/, packages/core/principles/, EXECUTION-PLAN.md, prior-art-evaluations.md, CLAUDE.md, templates).

Pre-existing residuals (NOT introduced by this PR)

Two failures exist on origin/staging independently of this branch — confirmed by running each against a clean origin/staging snapshot before commit:

  1. packages/core/hooks/pre-push.test.ts > invokes the remaining audit-self self-tests by literal path — pre-existing; this PR does not touch hooks/pre-push.ts or its test.
  2. audit-self/audit-ai-docs.ts(67,15): error TS2345 (BuildVisitor type) — pre-existing tsc warning at visit() call site (line 67); my changes are at lines 155-185.

Both should be tracked separately, not on this scope.

Scope-out

  • Not a capability commit (no new dependency, no new ≥50/≥80 LOC file). No Prior-art: trailer required.
  • No upstream / framework changes — purely a test-discipline patch.
  • No vi.mock('node:child_process') (R-phase §3 Option 3 falsifier fired: global module replacement breaks the :344 real-subprocess contract — see R-phase §3 trade-off table).

…stTimeout 120s ceiling

Inject optional `opts.execSync` seam into `probeR4()`; default to the real
`execSync` from node:child_process so prod behaviour is byte-for-byte preserved.

Test impact:
- 2 warm-path probeR4 tests (`hasTsconfig && !hasTsMorph`, `hasTsMorph present`)
  use a fast stub → 1-2ms warm-cache (measured twice).
- :344 contract test (`tsconfig.json exists but ts-morph missing`) keeps real
  execSync via bare `probeR4(dir)` call → ~1.3s warm-cache (preserved). Semantic
  preservation of the cold-cache subprocess contract is the design intent of
  DN-1 Path C — see research-patches/2026-05-25-slow-test-triage.md §3.

Add a documentation ceiling in root vitest.config.ts: testTimeout MUST NOT
exceed 120_000 without a paired slow-test-triage R-phase (DN-3 Option A).
Future bumps fix the slow path, not raise the lid.

§1.7 Skipped: localised refactor of audit-ai-docs.ts + its test + 1-line
vitest.config.ts policy comment; no .claude/rules/, no packages/core/principles/,
no CLAUDE.md, no template, no agent — no discipline-rule surface to
forward/backward-check against.
@artyhoo
artyhoo merged commit 937c968 into staging May 25, 2026
22 checks passed
@artyhoo
artyhoo deleted the refactor/slow-test-triage-iphase-dn1c branch May 25, 2026 19:39
artyhoo added a commit that referenced this pull request May 25, 2026
…op stale L160-171 label (#235)

Two cosmetic follow-ups to PR #233 (cold-reviewer MINOR #1 + #2):

1. Move `fastExecSyncStub` from module-level into the `probeR4() — execSync
   call content` describe block (its sole consumer). Module-level placement
   risked leaking into unrelated tests if the file extends; scoped placement
   removes that pollution surface.

2. Replace the stale `L160-171` reference in the comment header + describe
   title with stable wording (`probeR4() — execSync call content`). Line-
   number labels rot whenever lines are inserted above them — this PR's own
   move + the DN-1 Path C insertion already invalidated them. The remaining
   `L167` label on a sibling describe is left untouched (out of this PR's
   scope — user instruction targeted L160-171 only).

No behavioural change: 191/191 tests pass, stubbed warm-path tests still
1-2ms, contract test still ~1.3s warm. Net diff: 24+/21- (~3 line delta).
artyhoo added a commit that referenced this pull request Aug 1, 2026
…billing profile (#1204)

## Summary

Stage B of the token-economy research umbrella: survey the candidate levers for reducing the expensive-tier bill, each evaluated against the measured billing profile stage A ships (85.5% of weighted spend = context re-submission; median-session residency multiplier 21.2×). Four seed candidates get the full W2 treatment (BFR §3 sweep, T16 problem-class statement, §2.1 cost line with arithmetic, two-axis verdict, cost gate, falsifier); a four-phrasing search sweeps for mechanisms absent from the seed list; six next-stage proposals are ranked by the §2.1 cost line they attack. Zero build — proposals only; the consumer is the Opus distillation seat that merges stages A+B into the single artefact the operator reads.

Headline verdicts (provisional, distillation seat adjudicates): **RTK — operator DEFER / shipped REJECT-provisional** (attributable share 1.9-3.5% of total weighted cost; saving 1.7-3.1% after the 89% removal factor — honest arithmetic, not the vendor's per-command number); **progressive-disclosure gap — the largest measured lever** (attacks the resident-context head directly); **native CC features — ADOPT-continue** (configuration + discipline, no new adoption); **engineering plugin — DEFER-with-trigger** (0% on the advertised surface; harvested-verdict probe PENDING).

## Changes

- New research-patch `docs/meta-factory/research-patches/2026-08-01-token-economy-s-b-candidates.md` (599 lines; the 600-line gate leaves 1 line of headroom by design — compression paid for every rework addition).
  - **W1** — own-stack enumeration (progressive disclosure shipped, measured seat/dispatch economy, model-cost routing, arch-v2 umbrella overlap labels) with file:line citations.
  - **W2** — four candidate blocks, each with the six mandated items; verdicts differ per axis where the axes genuinely differ.
  - **W3** — four quoted WebSearch phrasings for unnamed mechanisms; new candidates surfaced (CWL structured eviction → WATCHLIST, prompt-prefix-stability audit → ADOPT-as-discipline, structured-output-format audit → DEFER, bounded-session+watch-list → already shipped as `cold-seat-economy.md`); the negative-existence claim («no production-grade Read-result compressor surfaced») runs the explicit 6-item checklist and lands `coverage insufficient` (T14), not «category clean».
  - **W4** — six ranked next-stage proposals (P1 prefix-stability → P2 disclosure-gap → P3 sub-agent delegation → P4 Bash-output skill → P5 output-format audit → P6 RTK operator-axis trial), ordered by attacked cost line; no winner crowned.
- `docs/meta-factory/prior-art-evaluations.md` — one appended SSOT row **#233** (RTK: operator DEFER / shipped REJECT-provisional, with Verdict / Rationale / Trigger to revisit).

## Prior-art consult

- [x] All commits carry `Prior-art:` trailers (`skipped — research-patch only` — no capability added: no dependency, no module, no code).
- [x] New capability area (RTK / output-filter proxies) → SSOT row #233 appended in the same commit as the evaluating patch, with Verdict / Rationale / Trigger to revisit.
- [x] No existing SSOT entry matched RTK (grep verified in-patch); no `Last reviewed` touch due.
- [x] Candidate sweeps ran WebSearch ≥3 phrasings + DeepWiki per candidate (quoted verbatim in each W2 block — the round-1 review rejected an unquoted sweep and it was redone quoted).

## Test plan

- [x] `bash scripts/host-verify.sh token-economy-research-s-b` → **4/4 PASS on Darwin (host, not container)**, re-run after the merge-forward onto post-#1203 staging.
- [x] `bash scripts/run-local-ci-sweep.sh` → PASS (diff-scoped).
- [x] Principles 08 + 10 → 12/12 (inside host-verify).
- [x] `wc -l` = 599 < 600.
- [x] Manual smoke: `git diff --name-only origin/staging...HEAD` returns exactly the two permitted paths.

## Provenance

Kickoff `.claude/orchestrator-prompts/token-economy-research-s-b/kickoff.md` (merged to staging #1200, revised #1201/#1202) · base `origin/staging` (merged-forward onto post-#1203) · substrate **aif task `5bf80b65-9de7-4648-a6cb-15f3120dc93e`**, `bridge-profile: Z.AI GLM-5.2 SDK` (Tier-1 executor per CLAUDE.md `Task-tier routing`) · host-side egress + review by the dispatching session (Opus 5) · fidelity **Round 1**.

## Review findings

**Cold code-review, round 1** (fresh Opus seat, dialogue-blind; re-fetched external sources, re-computed arithmetic) → **REVISE**, 3 blocking + 8 non-blocking. The blockers:
- *B1* — the T16 «wrong SURFACE» evidence claimed Bash output is «~0.03%» of resident context: a denominator category error ~100× off (tokens counted once at entry vs cache-READ raw, which counts every re-read). Corrected to 3.1% (mid-session) / 6.2% (turn-1 entry); the patch's own §3 independently lands 1.9-3.5%. Conclusion weakened, not reversed — and the wrong number had already reached SSOT row #233, amended per that file's stated convention (§3: git history is the audit trail).
- *B2* — `CLAUDE_CODE_SIMPLE` does not exist; it was asserted as twice-confirmed (DeepWiki + context7) inside the own-stack section that exists to forbid recall. Retracted in place; the affected channel recorded `INCONCLUSIVE`.
- *B3* — candidate 4 dropped required W2 items under a kickoff «reduced block» provision that does not exist (`grep -ic reduced kickoff.md` → 0). Full W2 treatment delivered on rework, queries quoted; only the genuinely-unreachable staging-presence probe stays PENDING.
- Non-blocking: an uncited «~95% capacity» compaction threshold (retracted), a substituted checklist item, two mutually exclusive superlatives, a secondary-source attribution, two 404 URLs, a mislabelled arXiv title, three unquantified feature estimates.

All routed back as one aif `request_changes` round (rework cost: $8.07 / 588k tokens on the executor tier).

**Cold delta seat, round 2** (a *fresh* seat handed only the incremental diff + the round-1 findings, per `cold-seat-economy.md §3`) → confirmed B1-B3 and M1-M8 fixed by its own arithmetic, then **REVISE** on one new MAJOR plus four MINORs the rework itself introduced. All five were fully specified with no judgment left, so they were fixed host-side in `493ed4ae49` (disclosed there, not squashed into the worker's commits) rather than spending a third executor round:
- MAJOR — the replacement trigger-sweep row claimed «18 entries» where the quoted grep returns **26**, classifying 12 — a mis-counted population inside the row whose purpose is to stop rows reading as complete. Now: 26 entries, 12/26 classified, remaining 14 fire-checked only, coverage stated per T14.
- MINORs — the «100k-token threshold» was the API cookbook's figure attributed to the harness (now `INCONCLUSIVE`); a share-vs-saving label mismatch vs SSOT row #233; Read called the largest tool-result class where Bash leads (now second-largest, Bash named); a self-measurement quote already 34 chars stale (now a band — an exact self-quote goes stale with every edit pass).

**Open MINORs, accepted deliberately (fidelity seat, graded MINOR):** candidates 3/4 render the T16 statement without the literal `Evidence:` clause (substance adjacent in both); `Coverage:` delivered as a `## Coverage` section rather than a literal line. Not edited — invalidating a fresh GO to satisfy literal-string readings is the worse trade (`cold-seat-economy.md §1`).

## Fidelity verdict

FIDELITY: GO
Basis: .claude/orchestrator-prompts/token-economy-research-s-b/kickoff.md
Round: 1
Audited-SHA: 7cbb9db
Evidence: docs/meta-factory/research-patches/2026-08-01-token-economy-s-b-candidates.md:1 — mandated filename + first-line scope comment; one W2 block per seed candidate (:89/:177/:242/:344) each carrying sub-items 1-6; SSOT row #233 appended at docs/meta-factory/prior-art-evaluations.md:306.
Findings: 2 MINOR — (1) candidates 3/4 omit the literal `Evidence:` clause of the verbatim T16 form (substance adjacent at :278/:368); (2) `Coverage:` delivered as a `## Coverage` section, content obligation met. No missing, no extra, no diverged deliverable; descopes clean (no implementation, no crowned winner, no stage-A re-derivation, shipped-axis kept to provisional one-liners; one PR, no new umbrella).

**Watch-list for any future round on this file** (the fidelity seat's, carried so a later reviewer inherits substance without a transcript):
1. Filename + first line are load-bearing: the §6 host-verify glob keys on `token-economy-s-b` (disjoint from stage A's glob so a concurrent file cannot mask absence); principle 10 fails without the first-line scope comment.
2. The T16 statement is specified verbatim; two of four candidates already drop the `Evidence:` clause — drift reappears there first, and it is the clause separating a real problem-class match from name-adjacency.
3. Every cost estimate must name its §2.1 row and express reduction as a share of TOTAL weighted cost — vendor per-command percentages read large while the measured head is resident context (85.5%). Candidate 1's arithmetic is where this is most likely to be «simplified» back into a vendor number.
4. W4 ranks FOLLOW-UP STAGES by cost line, never candidates — that migration is the K6 framing bias the seat separation exists to prevent.
5. `PENDING-STAGE-A` / `PENDING — verdict not yet harvested` are contract-grammar, not placeholders; replacing one with an inferred number is the silent-fork failure §4a forbids.
6. 599 of 600 lines — any future addition must remove lines elsewhere.

## Parked questions

none triggered the kickoff's park contract; the engineering-plugin harvested-verdict probe is recorded `PENDING` inside the patch (a stated dependency, not a parked fork).

## §1.7 Self-discipline check (REQUIRED if PR touches discipline-bearing files)

### §1.7 Skipped: research-patch + one append-only SSOT row — this PR introduces and extends no discipline rule, touches no `.claude/rules/**`, no `packages/core/principles/**`, no `CLAUDE.md` and no shipped template; the `prior-art-evaluations.md` touch is a single new register row (#233) in that file's own append-only schema, which is the register's normal operation, not a change to the discipline it encodes.
artyhoo added a commit that referenced this pull request Aug 1, 2026
…ges, operator forks (#1205)

## Summary

Stage 3 of the token-economy funnel ([design](../blob/staging/docs/superpowers/specs/2026-08-01-token-economy-research-design.md)): GLM gathered stages A (#1203) and B (#1204), an Opus seat distills, the operator decides **from this file alone**. 123 lines against ~1,060 lines of raw material — the compression is the deliverable, and the funnel is itself the token-economy pattern it studies.

The distillate merges stage A's measured numbers with stage B's verdicts into one ranked lever list, holds the `claudeMdExcludes` leak apart as a **mechanism bug rather than an optimization lever**, proposes five next stages under `arch-v2-context-pipeline`, and surfaces three genuine operator forks.

## Changes

- New `docs/meta-factory/research-patches/2026-08-01-token-economy-distillate.md` (123 lines) — the only file this PR touches.
  - **§1** five measured facts, each one line with its number, plus the denominator caveat stated once so every share inherits it.
  - **§2** the `claudeMdExcludes` leak — 186,539 cost-units/session, 24.7% of the always-on bill, paid for content the project already declared cold. Deliberately **not** ranked against levers: framing «stop paying for what we declared we would not pay for» as an optimization choice would be wrong.
  - **§3** seven levers ranked by measured-impact-per-effort, each with the §2.1 cost line it attacks, an A-bound saving estimate, stage B's two-axis verdict, the BFR effort class, and a falsifier.
  - **§4** five proposed stages N1-N5, sequenced against the umbrella's existing S-A…S-F, with an explicit statement of where this seat **overrides** stage B's ordering and why.
  - **§5** five surviving unknowns with their consequence.
  - **§6** three operator forks as Option A → consequence / Option B → consequence.
  - **§7** §1.7 forward + backward self-review (see below — the backward-check earned its keep).

## Prior-art consult

- [x] The single commit pair carries `Prior-art: skipped — <rationale>`; this PR adds one research patch and no capability.
- [x] No new capability area surfaced — the distillate proposes no BUILD; every ranked lever is *cheap* under the BFR cost gate (text / skill / config edit). Stage B's RTK `DEFER` (SSOT #233, landed in #1204) is carried forward, not overridden: L1 is explicitly the config-only variant stage B left unevaluated.
- [x] No existing SSOT entry matched; no `Last reviewed` touch due.
- [x] context7 n/a — no library surface; the inputs are two merged in-repo research patches.

## Test plan

- [x] `npx vitest run packages/core/principles/13-phase-research-coverage-s17.test.ts` → **17/17** (this gate initially **rejected** the patch — see Review findings).
- [x] `npx markdownlint-cli2` on the new file → 0 errors.
- [x] `bash scripts/run-local-ci-sweep.sh` → PASS (diff-scoped).
- [x] `wc -l` = 123 < the 600-line pre-commit ceiling.
- [x] Arithmetic re-checked independently by the dispatching session before commit: `D` = 754,884 + 415,351 = 1,170,235; L5 head block 265,678/D = 22.7%; leak 8,799 × 21.2 = 186,539 → 24.7% of always-on / 15.9% of `D`; Bash 221,127/D = 18.9%, Read 156,975/D = 13.4%; digest 93,720/D = 8.0%. All reproduce.

## Provenance

Funnel design `docs/superpowers/specs/2026-08-01-token-economy-research-design.md` («Stage 3 — Opus distillation») · inputs = the two merged stage patches on `staging` (#1203, #1204) · base `origin/staging` · substrate **in-session cold Opus subagent** (not an aif task — the input was already on staging and the work is one compression pass, so a container round-trip would have bought nothing) · fidelity **n/a — see below**.

## Review findings

**The fidelity gate caught a real shortcut, and the fix produced the PR's headline finding.** The first push carried a *skipped* verdict on the argument that stage 3 has no kickoff, so there is no WHAT-conformance contract to audit against. `fidelity-verdict-in-pr-body` rejected it: a filled-in `## Provenance` section declares a substrate, which makes this a stage PR, and `skipped` is not available to one. The gate was right. The cheap way out — blanking Provenance to `n/a` — is a bypass the gate's own header names («bypassing requires either denying the substrate or altering the shipped heading»), i.e. exactly the `#discipline-theatre` this project exists to prevent. Instead a real cold seat was dispatched using the mechanism the agent spec already provides for kickoff-less stages: `agents/fidelity-auditor.md` Inputs item 1 permits the dispatching session to pass a **scoped section** as the intent statement, with `Basis:` citing `<path>#<section>`. It returned **GO** — and, asked to verify the §2 claim on its own merits rather than take it on trust, **identified the root cause the research had recorded as unknown**:

> `.claude/settings.local.json` (untracked, globally gitignored) lists **4** `claudeMdExcludes` entries in `**/`-glob form; the tracked `.claude/settings.json` lists **7**. Local settings *override* project settings, and for an array-valued key override means **replace, not union** — so the 3 rules present only in the project file are shadowed and inert. The leak set is exactly the `settings.json − settings.local.json` delta.

None of stage A's three carried hypotheses (path-resolution mismatch, secondary load trigger, loader ordering) was the cause. Reproduced independently twice — by the dispatching session and by the cold seat. Two consequences now in §2/§4: the 24.7% holds for **this machine only** (a container or CI runner without the overlay reads the 7-entry list and gets the full eviction — a per-machine configuration defect, not a repo defect, shipped consumers unaffected), and stage N1 is re-tiered from «1 or 2» to **operator-executed, not dispatchable**, because both fix surfaces are agent-unwritable, with the `00-rule-index.md` half split out as the genuinely Tier-1 piece. The gate's value here was not that it enforced a format — it forced a seat that found the answer.

**Numeric verification** was done by the dispatching session against the two merged patches (see Test plan). No number in the distillate is new; every one traces to `s-a-profile.md §…` or `s-b-candidates.md §…` inline.

**Principle 13 rejected the first commit**, and the fix produced the PR's most valuable finding. The gate demands real §1.7 self-review substance on post-cutoff research patches (not a bare `§1.7` heading — the `#discipline-theatre` case it closes). Writing the backward-check required enumerating the complete class *«artefacts that rank, size, or adjudicate context/token-economy levers»* — which surfaced `.claude/orchestrator-prompts/session-start-token-audit/` (`done.md`, PR #1188, closed **2026-07-31**): an umbrella that had **already banked a −39% trim** (39,021 → 23,864 tokens host-cc) using the very `claudeMdExcludes` lever this distillate reports leaking, plus a `CLAUDE.md` hot/cold split on L5's exact surface. Two corrections followed:

- **§2 re-framed**: the leak is a **regression against an already-banked saving**, not an untested feature. All three leaking rules were authored 2026-07-21…07-31 — at or after that trim — which narrows the root-cause hypotheses to «the list was extended without re-verifying that the extension took effect» or «these three load via a second channel the excludes list does not govern».
- **L5 re-stated** as a *further* trim of an already-split `CLAUDE.md`, so its saving is not double-counted against #1188's.

Without that sweep this patch would have proposed re-doing work that shipped the day before. Recorded per surface as SWEPT-CLEAN / GAP-FOUND / SUPERSEDED-WITH-REASON in the T21 enumeration format.

**One deliberate supersede, declared not silent:** §4 re-ranks stage B's P1-P6 (P4 promoted 4th → 1st; P6 dropped below the ranked set; P5 parked), with the reason stated per proposal. Stage B's per-candidate verdicts, sweeps and falsifiers stand unchanged — only the ordering is overridden, and a silent re-ranking would have left two live orderings in the same folder.

## Fidelity verdict

FIDELITY: GO
Basis: docs/superpowers/specs/2026-08-01-token-economy-research-design.md#stage-3-opus-distillation
Round: 1
Audited-SHA: 9932658
Evidence: docs/meta-factory/research-patches/2026-08-01-token-economy-distillate.md:36-50 — §3's ranked lever list L1-L7, each row carrying an A-number, a B two-axis verdict, an effort class and a falsifier; :52-62 — §4's N1-N5 sequenced against the umbrella's existing S-A…S-F; :5-13 — lands under research-patches/, references arch-v2-context-pipeline, declares the shipped axis out of scope.
Findings: none missing, none extra, none diverged. Round-1 raised 3 MINOR; all 3 RESOLVED by `9932658cbf` and confirmed by the delta seat. Two non-blocking INFO nits recorded: §7's ≈27 kB is a self-measurement of a file containing the sentence that measures it (the "at or just past" hedge absorbs the fixed-point wobble; a bare "past" would not), and §2's "reproduced independently twice" is a provenance claim the delta seat could not re-verify without reading files, accepted on audit-trail consistency since the fidelity seat is one of the two sources.

**Seat-economy note (`cold-seat-economy.md` §1/§3) — the block above is a round-1 verdict re-established by a delta refresh, not a round 2.** The round-1 GO was issued at `c97994d438`; the follow-up commit moved the SHA but not the substance the seat judges — `git diff --name-only c97994d..HEAD` returns the one deliverable path, unchanged permitted-file set, unchanged descopes. So the verdict was re-established by a **fresh narrow delta seat with all four hunks inlined verbatim in the dispatch prompt**, not by a full re-audit and not self-issued: **0 tool calls, 87k tokens, 68 s** — against 131k / 12 tool calls / 209 s for the full round-1 audit. That is the §3 measurement being used, not just cited. The delta seat also flagged, correctly, that had it been handed a file *list* instead of the hunks it should have escalated rather than refreshed.

## Parked questions

none. The three genuine forks are **not** parked — they are stated as §6 decisions for the operator (D1 always-on head trim, D2 measure-first vs ship-cheap-levers-first, D3 close or drop the `engineering`-plugin thread), each as Option A → consequence / Option B → consequence. They block nothing in this PR; they gate stage N5 and the N2/N3 ordering.

## §1.7 Self-discipline check (REQUIRED if PR touches discipline-bearing files)

### §1.7 Skipped: research-patch only — this PR introduces and extends no discipline rule and touches no `.claude/rules/**`, no `packages/core/principles/**`, no `CLAUDE.md`, no `prior-art-evaluations.md` and no shipped template; the full Forward + Backward self-review that principle 13 requires of the artefact itself lives inside the patch at its §7, where it belongs, rather than being duplicated into this PR body.
artyhoo pushed a commit that referenced this pull request Aug 1, 2026
Incident 2026-08-01: token-economy stage B (#1204) and arch-v2 S-C (#1197)
each appended a prior-art-evaluations.md row claiming ID 233 — "next free ID"
computed independently on two branches forked from the same staging. Principle
08 verified only that a cited ID EXISTS, so both PRs were green in isolation;
the duplicate would have been born at merge, silently splitting every future
#233 citation between two entries of an append-only register keyed by ID.
Caught by a session-side final probe; the instance was fixed by renumbering
S-C's row to 234 on its own branch. This commit closes the CLASS: the second
PR to land now fails CI instead of minting the collision.

Mechanics: loadSsotEntryIds() now delegates to an exported
collectSsotEntryIds() that preserves duplicate sightings; the citation-target
behaviour (Set of ids) is byte-identical. Two new tests: the live-register
uniqueness assertion (names the duplicated IDs and the renumber remedy in its
failure message) and an anti-tautology mutation proving the detector fires on
a synthetic duplicate. 9/9 green; tsc --noEmit clean.

Channel note (rule-enforcement-channel-selection §1): the violation is
mechanically detectable only at the MERGED state — two green branches each
hold a consistent register, so edit-time and pre-push on either branch cannot
see the other; CI on the second PR (whose branch context contains both rows
after merge-forward) is the earliest reachable channel.

Prior-art: skipped — extends an existing principle test with a uniqueness arm over the same SSOT file, no new capability.
artyhoo added a commit that referenced this pull request Aug 1, 2026
…1207)

## Summary

Closes the class behind the SSOT ID collision found at the token-economy close-out: `prior-art-evaluations.md` is an append-only register keyed by entry ID, but principle 08 verified only that a cited ID **exists** — never that it is **unique**. Two branches forked from the same staging each computed "next free ID = 233" (#1204 RTK, #1197 per-role L2); both were green in isolation, and the duplicate would have been born at merge, silently splitting every future `#233` citation between two entries. The instance was fixed by renumbering #1197's row to 234 on its own branch (`9ac2f73c29`); this PR ships the invariant so the *next* collision fails CI on the second PR instead of landing.

## Changes

- `packages/core/principles/08-prior-art-cited.test.ts`:
  - `loadSsotEntryIds()` now delegates to an exported `collectSsotEntryIds()` that preserves duplicate sightings. The citation-target behaviour (the `Set` of ids) is byte-identical — no existing check changes meaning.
  - New test: live-register uniqueness assertion; its failure message names the duplicated IDs and the remedy (renumber the later row, update citing files).
  - New mutation test: anti-tautology proof that the detector fires on a synthetic duplicate (`[1,2,1,2]` → duplicates `[1,2]`).

## Prior-art consult

- [x] Commit carries `Prior-art: skipped — extends an existing principle test with a uniqueness arm over the same SSOT file, no new capability` (no dependency, no module ≥50 LOC, no new dir).
- [x] No new capability area — this is the existing principle 08 growing one arm over the file it already parses.
- [x] No SSOT entry matched; no `Last reviewed` touch due.
- [x] context7 n/a — vitest assertion over an in-repo markdown table.

## Test plan

- [x] `npx vitest run packages/core/principles/08-prior-art-cited.test.ts` → **9/9** (7 existing + 2 new).
- [x] Discrimination shown, not assumed: the mutation test fails a synthetic duplicate register; the live register passes (staging currently has no duplicate — verified `sort -n | uniq -d` → empty).
- [x] `npx tsc --noEmit -p packages/core` → clean.
- [x] Sweep: `md-ci-only`, `typecheck`, `agnosticism` PASS; `vitest-hooks` **red, pre-existing** — see Review findings.

## Provenance

n/a — non-stage PR: in-session fix by the session that found the collision, no kickoff, no dispatched worker. Origin incident and instance-fix are documented in the commit body and in #1197's `9ac2f73c29`.

## Review findings

**Pre-existing red surfaced, deliberately not fixed here (one concern per PR):** the local sweep's `vitest-hooks` gate fails on 2 of 1,043 tests — `check-worker-dispatch-channel.test.ts` C1 and `validate-prompt.test.ts` C1 ("linked worktree, PATH scrubbed" scenarios). Discrimination against merge-base per `/harvest §3`: the same 2 tests fail on a **clean `origin/staging` worktree** under the full `test:hooks` run and **pass in isolation** on both staging and this branch — an environment-sensitivity under full-suite parallelism, not a defect this diff introduces (the diff touches one principles test file, unrelated to hooks). Staging CI on the same code is green, so the GitHub runner does not reproduce the interference. Left as an observation for a separate task.

**Channel note (`rule-enforcement-channel-selection.md §1`):** the violation is mechanically detectable only at the *merged* state — two green branches each hold an internally-consistent register, so edit-time and pre-push on either branch cannot see the other. CI on the second PR (whose branch context contains both rows after merge-forward) is the earliest reachable channel; this is the documented exception where CI is not the last resort but the first reachable gate.

## Fidelity verdict

FIDELITY: skipped — non-stage in-session fix with no kickoff and no dispatched substrate; the deliverable is a 2-test extension of an existing principle test, verified by its own mutation arm and a clean typecheck rather than by a WHAT-conformance seat.

## Parked questions

n/a — non-stage PR.

## §1.7 Self-discipline check (REQUIRED if PR touches discipline-bearing files)

### §1.7 Forward-check applied

The new invariant complies with: [no-paid-llm-in-ci.md](../blob/staging/.claude/rules/no-paid-llm-in-ci.md) — deterministic regex + Set over a markdown file, zero LLM calls (packages/core/principles/08-prior-art-cited.test.ts:117-135); [rule-enforcement-channel-selection.md §1](../blob/staging/.claude/rules/rule-enforcement-channel-selection.md) — mechanically-detectable violation → gate, placed at the earliest channel that can see it (merged-state CI; edit-time cannot, see Review findings channel note); [attention-is-not-a-mechanism.md §1](../blob/staging/.claude/rules/attention-is-not-a-mechanism.md) — replaces «a session-side probe happened to notice» (bare attention, which is exactly how this incident was caught) with a deterministic gate; [build-first-reuse-default.md](../blob/staging/.claude/rules/build-first-reuse-default.md) — REUSE: extends the existing principle test in place, no new artefact, no dependency; anti-tautology mutation arm per the principle-test house pattern (08-prior-art-cited.test.ts:150-156, mirroring the existing broken-ref mutation at :139-145).

### §1.7 Backward-check applied

Class of this change = *checks that parse `prior-art-evaluations.md` entry IDs*. Enumerated by `grep -rln "prior-art-evaluations" packages/core --include="*.ts"`: (a) `packages/core/principles/08-prior-art-cited.test.ts` — the surface extended here; its own loader was reused so the uniqueness arm and the citation-target arm cannot disagree about what counts as an entry row (single `rowRe`, 08-prior-art-cited.test.ts:128). (b) `packages/core/hooks/checks/prior-art.ts` — SWEPT-CLEAN: parses commit trailers and `package.json` diffs for the capability-commit gate; it never reads SSOT entry IDs, so no parallel ID-parsing logic exists to drift (verified `grep -n "233\|entry.*id\|rowRe" packages/core/hooks/checks/prior-art.ts` → no ID-table parsing). (c) `packages/core/principles/10-research-patch-annotation.test.ts` and `13-phase-research-coverage-s17.test.ts` — SWEPT-CLEAN: operate on `research-patches/` files, not the SSOT register. No other artefact parses the §4 ID table; nothing superseded.
artyhoo added a commit that referenced this pull request Aug 1, 2026
…SOT #233 (#1197)

* docs(arch-v2-s-c): S-C stage — L2 channel verdict (DEFER/null) + SSOT #233

arch-v2-context-pipeline S-C: BFR-disciplined verdict over the 5-option
L2 channel space, on top of ADR-2's 4-row population table precondition.

Verdict: DEFER the L2 build; null option adopted. Five independent lines
of evidence converge — need not established (C10), no single option reaches
all 4 population rows, the aif runtime already does partial per-role ambient
shaping via effectiveSystemPromptAppend (subagentQuery.ts:681-684), the
external evidence points subtractive (Anthropic 2026-07-24 80%-removal;
obra/superpowers retired review loop per SSOT #231), and the falsifier is
concrete and operational.

R6 /app/ re-check: VERIFIED (not INCONCLUSIVE — plan's binding fact was
reasonably inferred from "docker unavailable" but /app/ is directly readable;
destination-environment-verification.md §3 governs container→HOST suite
re-runs, not /app/ file reads). All six anchor sites match verbatim.

BFR §3 mechanism run, not asserted: SSOT consult (#101/#228/#229/#231) +
DeepWiki ×3 phrasings + WebSearch ×3 phrasings; context7 excluded per
kickoff (problem-class, not library API).

§1.7 backward-check delegated to agents/backward-sweep-auditor.md per T21
binding — cold agent enumerated 14 in-repo sibling surfaces + 2 NOT-IN-REPO,
all SWEPT-CLEAN, 0 GAP-FOUND. Surface list ≠ diff's own files (conformant).

S-D tier assignment: on the null verdict, S-D becomes a Tier-1 L2-closure
PR (retirement note + done.md, no build). Marker decision recorded in §7
of the research-patch.

Acceptance (kickoff §2):
- population table complete (4 rows, file:line evidence per cell) ✓
- 5 options adjudicated; null argued ✓
- BFR mechanism run with queries + results quoted ✓
- T16 problem-class match per ADOPT/ADAPT ✓
- research-patch exists; SSOT row appended; principle 08/10/12 GREEN ✓
- S-D tier in PR body (§7 of patch) ✓
- §1.7 forward + backward ✓
- Zero build: no hook/resolver/skill/rule in diff ✓
- host-verify 3/3 PASS on Linux ✓

Prior-art: prior-art-evaluations.md#233 (this commit registers the L2 channel verdict capability class — row 233 IS the evaluation; no separate code artefact, markdown-only).

* fix(arch-v2-s-c): renumber SSOT row 233 → 234 — ID collision with RTK (#1204)

This branch and token-economy stage B (#1204, merged first) both claimed SSOT
ID 233. prior-art-evaluations.md is an append-only register keyed by ID;
principle 08 verifies that a cited ID EXISTS but not that it is UNIQUE, so both
PRs were green in isolation and the duplicate would have been born at merge.
RTK keeps 233 (first to land on staging); this branch's per-role-L2 row becomes
234, and the l2-channel-verdict patch's "Next free ID" note moves with it.
Merged origin/staging in (merge-forward, never rebase a published branch) so
both rows now coexist in this branch's copy of the register.

The class-level fix (uniqueness check in principle 08) ships separately on the
token-economy session branch — one concern per PR.

Prior-art: skipped — ID renumbering + merge-forward bookkeeping, no new capability.

---------

Co-authored-by: Test <test@example.com>
artyhoo added a commit that referenced this pull request Aug 2, 2026
…falsifier NOT triggered (#1208)

Closes the S-B candidate-1 falsifier with measurement, not arithmetic. On this
project's actual command mix (599 Bash calls across 5 top sessions), RTK saves
9.4% of Bash-output bytes — which translates to ≈1.77% of total resident-context
weighted cost, below the 5% ADOPT threshold and within S-B's 1.7–3.1% arithmetic
range. DEFER confirmed.

Key findings:
- The vendor 89% does not reproduce on our mix: 58% of our Bash bytes is already-
  piped head/tail output RTK cannot improve, and 71% of our Bash CALLS are
  compound commands RTK refuses to rewrite.
- Caveat (c) fires in the OPPOSITE direction: RTK's failing-test fallback
  INFLATES output (+34%) by emitting full Node stack traces raw vitest trims.
- Independent corroboration: JetBrains benchmark (425 trials, Jul 2026) found RTK
  +7.6% more expensive at low reasoning effort (p=0.004), ±0% at high effort.

The S-B proposal P4 (config-only equivalent) is reinforced: the agent already
self-truncates via head/tail/grep — a skill codifying that habit captures the one
real saving (verbose test-runner dumps) without the binary. Not built here;
flagged for the Opus distillation seat.

No SSOT row added/edited (#233 unchanged — hard boundary). Zero build.

§1.7 Forward + Backward checks applied (see patch footer).

Prior-art: skipped — research-patch only, no capability (no dependency, no module, no code); the load-bearing candidate RTK is already SSOT row #233, cited not re-added.

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