Skip to content

Materialize a frozen bundle, and prove two copies are one repository - #446

Merged
MongLong0214 merged 1 commit into
devfrom
cdeb-02-materializer
Aug 7, 2026
Merged

Materialize a frozen bundle, and prove two copies are one repository#446
MongLong0214 merged 1 commit into
devfrom
cdeb-02-materializer

Conversation

@MongLong0214

Copy link
Copy Markdown
Owner

Closes #445. CDEB-02 — the second infrastructure ticket of the protocol (bench/cdeb/PRD.md v1.2). CDEB-01 landed in #444.

What this owns

Every CDEB comparison rests on one invariant: the ON and OFF arms of a task/repeat pair see byte-identical repository state, and the only difference is the frozen agent settings. bench/cdeb/freeze/repository-bundle.ts owns that end to end — the §6.1 bundle with its six-field identity, offline materialization into a detached checkout, and the §6.2 identity both arms are compared by.

sameHistoryMismatches returns the mismatched field names, so a violation says what diverged rather than only that something did.

Deliberately new code, and why the PRD says so

bench/workspace.ts with seedRecords: false strips the trailer block out of seeded commits — exactly the OFF-arm construction §6.3 prohibits. The PRD names it as the one helper the materializer must not touch. Nothing here imports it, and the mutation test builds that forbidden shape independently to prove the gate catches it: a trailer-stripped history fails with commit_message_digest among the mismatches, which identifies the kind of divergence rather than merely its existence.

Digest boundary (v1.2 §6.2)

Identity covers commits, trees, refs and the notes mirror; it excludes .git/ internals. The working-tree digest reads git ls-files -s, which never sees the product's lazily created index or MCP lifecycle log — so an ON arm that has been queried does not "differ" from an OFF arm that has not.

One git behaviour shaped the order

Git refuses to fetch into the branch a clone checked out, so the copy detaches onto the snapshot first and only then restores the bundle's refs to their local names. The contract is a detached checkout anyway.

Also: git bundle create --all includes refs/notes/* only by configuration, so the notes ref is passed explicitly. A bundle that silently dropped the mirror would materialize an OFF arm by accident.

Tests — 5

  • two materializations of one bundle report zero mismatches (the §6.2 proof)
  • the notes record and the trailer record are both readable in the copy
  • a tampered bundle and a missing bundle each refuse with the named reason
  • the trailer-stripped history fails the gate with commit_message_digest named

Verification

Full suite: 96 files, 2201 passed, 1 skipped. bench/tsconfig.json typecheck clean. test/dogfood.test.ts re-run after committing: 9 passed.

CDEB-02. Every CDEB comparison rests on one invariant: the ON and OFF arms of a
task/repeat pair see byte-identical repository state, and the only difference
between them is the frozen agent settings. This module owns that invariant --
creating the §6.1 bundle with its six-field identity, materializing it offline
into a detached checkout, and computing the §6.2 identity both arms are
compared by. The gate returns the mismatched field names, so a violation says
what diverged rather than only that something did.

Deliberately new code rather than a reuse. `bench/workspace.ts` with
`seedRecords: false` strips the trailer block out of seeded commits -- exactly
the OFF-arm construction §6.3 prohibits -- and the PRD names it as the one
helper the materializer must not touch. Nothing here imports it, and the
mutation test builds that forbidden shape independently to prove the gate
catches it: a trailer-stripped history fails with `commit_message_digest` named,
which identifies the kind of divergence and not merely its existence.

The digest boundary follows the v1.2 rule: identity covers commits, trees,
refs and the notes mirror, and excludes `.git/` internals -- the working-tree
digest reads `git ls-files -s`, which never sees the product's lazily created
index or lifecycle log, so an ON arm that has been queried does not "differ"
from an OFF arm that has not.

One git behaviour shaped the materialization order: git refuses to fetch into
the branch a clone checked out, so the copy detaches onto the snapshot first
and only then restores the bundle's refs to their local names. The contract is
a detached checkout anyway.

Limit: `git bundle create --all` includes refs/notes only by configuration, so the notes ref is passed explicitly -- a bundle that silently dropped the mirror would materialize an OFF arm by accident
Ruled-out: reusing bench/workspace.ts for materialization | its record-stripping mode is the §6.3 prohibited control, and a helper that can build the forbidden shape should not be in the path that exists to prevent it
Ruled-out: comparing arms by bundle digest alone | both arms come from one bundle, so the bundle digest cannot catch a materialization that diverged after import; the §6.2 identity is computed from each working copy
Warn: a materialization whose digests mismatch the freeze throws rather than warns -- it is a different repository, and running an arm in it compares two experiments while calling them one
Blast: local
Undo: easy
Certainty: firm
Verified: two materializations of one bundle report zero mismatches; the notes record and the trailer record are both readable in the copy; a tampered bundle and a missing bundle each refuse with the named reason; and the trailer-stripped history fails the gate with commit_message_digest among the mismatches
Provenance: authored
Record-Id: r-cdebmat02
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

CommitLore — record lint

Trailers: clean — 1 commit in origin/dev..8080420d9954593489f866411a5653dc51aafb4e
Active constraints: 1 limits · 2 ruled-out · 1 warnings — from 1 record over 2 changed paths

Active constraints for the paths this PR touches

Limits (1)

  • r-cdebmat02 8080420git bundle create --all includes refs/notes only by configuration, so the notes ref is passed explicitly -- a bundle that silently dropped the mirror would materialize an OFF arm by accident

Ruled out (2)

  • r-cdebmat02 8080420 — reusing bench/workspace.ts for materialization | its record-stripping mode is the §6.3 prohibited control, and a helper that can build the forbidden shape should not be in the path that exists to prevent it
  • r-cdebmat02 8080420 — comparing arms by bundle digest alone | both arms come from one bundle, so the bundle digest cannot catch a materialization that diverged after import; the §6.2 identity is computed from each working copy

Warnings (1)

  • r-cdebmat02 8080420 (claim) — a materialization whose digests mismatch the freeze throws rather than warns -- it is a different repository, and running an arm in it compares two experiments while calling them one

git log --follow accepts exactly one pathspec, so renames are not followed for 2 paths; query one path at a time to follow its rename chain

Trailer violations fail this check. Active constraints are informational — they are what the repository already decided, not a verdict on this PR.

@MongLong0214
MongLong0214 merged commit 105df35 into dev Aug 7, 2026
8 checks passed
@MongLong0214
MongLong0214 deleted the cdeb-02-materializer branch August 29, 2026 01:58
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