Skip to content

fix(drift-sync): enforce the pin-file boundary in the checker, not the writer - #428

Merged
jpr5 merged 1 commit into
mainfrom
fix/drift-sync-gate-boundary
Sep 10, 2026
Merged

jpr5 merged 1 commit into
mainfrom
fix/drift-sync-gate-boundary

Conversation

@jpr5

@jpr5 jpr5 commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #423, from a four-reviewer retrospective review (all four
NOT-APPROVED, keep merged, fix forward). Every finding below was reproduced
against the real model-registry.ts / logic-pin.test.ts before the fix, and
every guard was mutation-proven after it.

1. The gate boundary is back in the checker

Admitting logic-pin.test.ts to ALLOWED_EXACT_FILES moved the only constraint
on the pin file out of the external gate and into the writer. model-registry.ts
is allowlisted too, so the pair was sufficient to silence a frozen surface.

RED — widen isClassifiedFamily to classify gpt-zeta by fiat, then
re-paste that surface's FROZEN checksum:

STEP 1 — widened isClassifiedFamily, pin test exit: 1
  → Frozen classification surface "isClassifiedFamily" changed
STEP 2 — re-pasted FROZEN.isClassifiedFamily pin: 60d59a5c43f3 -> 562ab1768a80
STEP 3 — gate-2 (vitest logic-pin.test.ts) exit: 0 | Tests 33 passed (33)
VERDICT ok= true reason= ok
drift-sync-check passed: changed files are data-only, classification pins intact

GREEN — same tree, same command, after the fix:

VERDICT ok= false reason= pin-file-not-a-membership-repin
src/__tests__/drift/logic-pin.test.ts is on the allowlist ONLY for membership
re-pins of excludeFamilies.{openai,anthropic,gemini},
includeFamilies.{openai,anthropic,gemini}, and this diff is not one: the edit
changed something other than the membership pins it is entitled to move

onlyPinsChanged was NOT the fix — it masks every pin: literal, FROZEN
checksums included, so the silenced tree reads as pin-only to it (asserted in a
test). The predicate is a reconstruction: re-apply exactly the entitled re-pins
to the pre-edit file and require byte equality with the post-edit file.
drift-sync-check gate-1b evaluates it over the git diff, keyed to
SYNC_REPINNABLE_KEYS; the writer evaluates it over what LANDED on disk, keyed
to the run's own re-pins.

2. The wrong-key pin rewrite

updateDataFrozenPin's adjacency check only matched QUOTED keys, and three real
DATA_FROZEN keys are unquoted — one directly after "excludeFamilies.gemini".

RED, against the real pin file, target entry's own pin unrecognisable:

knownVoiceModelFamilies pin BEFORE: 3897b6bd6fc370ef...
updateDataFrozenPin -> changed: true  locatorMiss: false
knownVoiceModelFamilies pin AFTER : eeeeeeeeeeeeeeee...
guard 2 onlyPinsChanged says safe: true

GREEN — entry located through the TypeScript AST, pin replaced span-exactly
inside its own literal:

updateDataFrozenPin -> changed: false  locatorMiss: true
knownVoiceModelFamilies pin AFTER : 3897b6bd6fc370ef...  (unchanged)

The "two independent guards" claim is gone from the comments: for a wrong-key
write it was one guard and a no-op. What is there now is one guard and one
external gate that does not trust it.

3. Exclude is complete, or it does not run

excludeFamilies and knownVoiceModelFamilies are deliberately disjoint and the
sync writes only the first.

RED, real files, gate-3 modelled on the real ws-realtime.drift.ts
computation:

reason= gate-failed
detail: [residual-critical-drift] UNKNOWN_REALTIME_MODELS=gpt-live — reverted
outcomes: [{"a":"excluded","f":"gpt-live"}]
revertFiles: [[model-registry.ts, logic-pin.test.ts]]
note still says Decision: exclude   -> repeats every night, forever

GREEN, both directions:

outcomes: [{"a":"needs-human-voice-seed-set","f":"gpt-live"}]  reverted: []
(registry untouched, gate never called, deduped note naming both surfaces)

# once a human has made the voice-models.ts half:
gate-3: ws-realtime UNKNOWN_REALTIME_MODELS=[]
reason= ok-applied | outcomes: ["excluded:gpt-live"] | reverted: []

The predicate keys on the voice SEED SET, not on the id's shape, and covers
include as well — the canary reads the seed set, not the classification. The
note template no longer advertises an auto-apply the sync will refuse.

4. Honest reporting

RED: reason= needs-human | registry written? false while
outcomes: ["added:openai/gpt-zeta"] and the commit body read
- added openai/gpt-zeta. GREEN: outcomes: ["needs-human-repin:..."],
empty commit body, and a deduped -pin-repin-failure.md note.
fix-drift.yml's "only ever edits model-registry.ts" comment is corrected.

Mutation proof (if (false) on every guard; baseline 152 passed)

Guard Mutated
checker gate-1b enforcement 3 failed
writer post-write pin verification 1 failed
updateDataFrozenPin entry/pin refusal 2 failed
voice-seed-set routing 1 failed
verifyPinFileEdit reconstruction 3 failed
verifyPinFileEdit allowed-key scope 3 failed

A seventh branch — the onlyPinsChanged pre-cut — survived, so it was demoted to
a message selector rather than kept: a guard that cannot change a verdict is not
a guard.

Gates

prettier --check 0 · eslint . 0 · pnpm typecheck 0 · vitest run 0
(5791 passed / 46 skipped) · actionlint 0 · commitlint 0.

Does not touch model-registry.ts's family lists (owned concurrently by the
gpt-live-1 classification, now on main and rebased under this).

…e writer

Admitting `logic-pin.test.ts` to `drift-sync-check`'s changed-file allowlist
moved the only constraint on that file out of the external gate and into the
writer. Because `model-registry.ts` is allowlisted too, that combination was
enough to silence a frozen surface: widen `isClassifiedFamily`, re-paste that
surface's FROZEN checksum, and gate-1 (allowlist) and gate-2 (the pin test,
whose oracle IS that file) both pass. Reproduced against the real tree —
`drift-sync-check` returned `reason=ok` for a tree where `gpt-zeta` had been
classified by fiat.

* New `scripts/drift-pin-file.ts`, imported by BOTH the writer and the checker.
  `verifyPinFileEdit` states the property as a reconstruction: re-apply exactly
  the entitled membership re-pins to the pre-edit file and require the result to
  equal the post-edit file byte for byte. `drift-sync-check` gate-1b evaluates
  it over the git diff (HEAD vs working tree), keyed to `SYNC_REPINNABLE_KEYS`,
  and refuses with `pin-file-not-a-membership-repin` (exit 23).
* `onlyPinsChanged` is no longer described, or used, as a guard. It masks EVERY
  `pin:` literal — the FROZEN logic checksums included — so it can tell neither
  which pin moved nor whether the sync may move it; it now only picks which of
  the refusal's two messages is true.
* `updateDataFrozenPin` locates the entry through the TypeScript AST and
  rewrites its own pin literal span. The forward text scan it replaces refused
  only on an intervening QUOTED key, and three real DATA_FROZEN keys are
  unquoted — so a target entry with an unrecognisable pin landed the write on
  `knownVoiceModelFamilies`'s pin, reported `locatorMiss: false`, and passed the
  old pin-only guard. Reproduced against the real file.
* The writer's own check now runs on WHAT LANDED, by reading the pin file back
  after writing it, and reverts both files on refusal. The version it replaces
  verified its own in-memory rewrite, so it could not return false from its only
  call site: mutating that call site to `if (false)` left the suite green.
* A DECIDED voice/audio family absent from `knownVoiceModelFamilies` is routed
  to a human instead of half-applied. `excludeFamilies` and the voice seed set
  are deliberately disjoint and the sync writes only the first, so applying one
  half left ws-realtime.drift.ts reporting UNKNOWN_REALTIME_MODELS at critical
  severity: gate-3 refused, both files reverted, the note still said
  `Decision: exclude`, and the identical apply/fail/revert/alert repeated every
  night forever. Proven end to end on the real files with the real canary
  computation, in both directions — routed while the seed set lacks the family,
  auto-applied with a clean canary once it has it.
* A re-pin refusal reports the classification as NOT APPLIED and leaves a
  deduped note. The refusals used to return with `action: "added"` for an edit
  that was never written, so the log, the commit body and `computeChangesetKey`
  all claimed work the run had not done.
* `fix-drift.yml`'s automation-boundary comment no longer says the sync "only
  ever" edits `model-registry.ts`.

Every guard above was mutation-proven: setting its condition to `if (false)`
takes the suite red. The one branch that survived that test — the pin-only
pre-cut — was demoted rather than kept, because a guard that cannot change a
verdict is not a guard.
@pkg-pr-new

pkg-pr-new Bot commented Sep 10, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@copilotkit/aimock@428

commit: 1ac660e

@jpr5
jpr5 merged commit 9180111 into main Sep 10, 2026
36 checks passed
@jpr5
jpr5 deleted the fix/drift-sync-gate-boundary branch September 10, 2026 23:47
@jpr5 jpr5 mentioned this pull request Sep 11, 2026
jpr5 added a commit that referenced this pull request Sep 11, 2026
Cuts the accumulated `[Unreleased]` work. **MINOR** — a new provider
surface (BytePlus Ark video) and new endpoints, no breaking changes.

**Prepared, not merged.** `publish-release.yml` fires on push-to-main,
so merging this publishes to npm, tags `v1.41.0`, cuts the GitHub
Release, dispatches the Docker build, and posts to Slack. Merge when you
want it live.

## What ships

Only **#424** (plus its follow-up **#429**, which fixes the same
never-released BytePlus code) touches the published package. Verified
against `package.json` `files` + `tsconfig` include/exclude:

```
git log v1.40.0..origin/main --oneline -- src/ ':(exclude)src/__tests__/' fixtures/ .claude-plugin/ skills/ CHANGELOG.md
```

…returns byteplus commits only. #422, #423, #425, #426, #427, #428 touch
scripts/, .github/ and docs/ exclusively and are deliberately **not** in
the CHANGELOG.

### Added
- BytePlus Ark (Seedance) video record/replay — submit, poll and
retrieve, stored as the raw Ark task envelope
- `--provider-byteplus` flag

### Changed
- `/api/v3` chat and image requests are attributed to the `byteplus`
provider
- `aimock-pytest` pin moves to 1.41.0

### Fixed
- Startup error when a BytePlus provider base already ends in `/api/v3`

## Version surfaces — seven, all bumped

Found by grepping the tree for `1.40.0`, not from a checklist. **Zero
occurrences of the old string remain** (excluding `CHANGELOG.md`
history, `fixtures/` and `pnpm-lock.yaml`):

| File | Field | 1.40.0 → 1.41.0 |
| --- | --- | --- |
| `package.json` | `version` | ✔ |
| `charts/aimock/Chart.yaml` | `appVersion` (chart `version` stays
`0.1.0`) | ✔ |
| `.claude-plugin/plugin.json` | `version` | ✔ |
| `.claude-plugin/marketplace.json` | `plugins[0].source.version`
(`^1.41.0`) | ✔ |
| `docs/index.html` | demo banner `aimock v…` | ✔ |
| `packages/aimock-pytest/src/aimock_pytest/_version.py` |
`AIMOCK_VERSION` npm pin | ✔ |
| `packages/aimock-pytest/README.md` | `--aimock-version` default | ✔ |

`AIMOCK_VERSION` **must** move this release:
`/api/v3/contents/generations/tasks` is a new server route, so a
default-download pytest user on the 1.40.0 pin would run a server
without it. `packages/aimock-pytest/pyproject.toml` is deliberately
untouched — that package versions on its own PyPI cadence.

There is **no version constant in `src/cli.ts`** and **no
`metadata.version` in `marketplace.json`** in this tree; both surfaces
exist only in the release checklist, not in the repo.

## Drive-by: the npm description has been `<div align="center">` since
the README got a centered header

`npm view @copilotkit/[email protected] description` returns the literal
string `<div align="center">`.

Both README-subtitle extractors — the inline `node -e` in
`publish-release.yml` and `syncDescriptionFromReadme()` in
`scripts/drift-sync.ts` — skip `#`, `[`, `![` and `http` lines but not
raw HTML, so they latch onto the README's opening `<div>` wrapper
instead of the bold subtitle two lines below. Both now also skip `<`,
and `package.json.description` is synced to what the fixed extractor
yields:

> Mock infrastructure for AI application testing — point your SDK at one
local port and every provider, protocol, and service answers
deterministically.

Without this the v1.41.0 npm page ships the same broken description.

## Gates (raw exit codes, local)

| Gate | Exit |
| --- | --- |
| `prettier --check .` | 0 |
| `npx eslint .` | 0 |
| `pnpm typecheck` | 0 |
| `npx vitest run` (5794 passed, 46 skipped, 189 files) | 0 |
| `pnpm build` | 0 |
| `npx commitlint --from origin/main --to HEAD` | 0 |

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01AvkmhXVLqSSEW6FvPQHSu5
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