Skip to content

C0-R · Register ReadSetSnapshot Artifact Identity - #35

Merged
jamespud merged 1 commit into
mainfrom
codex/c0-r-read-set-snapshot
Oct 22, 2026
Merged

jamespud merged 1 commit into
mainfrom
codex/c0-r-read-set-snapshot

Conversation

@jamespud

@jamespud jamespud commented Oct 22, 2026 •

Copy link
Copy Markdown
Owner

A. 基线

B. 修改

C0-R registers read_set_snapshot with prefix rset so consumers can calculate its independent content identity. The production change is exactly two additions (constant and prefix map); existing C0 encoding, domain separator construction, SHA-256, original types/prefixes, and all legacy algorithms stay unchanged.

Files (8):

  • backend/domain/canonical/canonical.go: constant/prefix.
  • backend/domain/canonical/read_set_snapshot_test.go: typed identity, equivalence, domain separation, mutation, unknown-type/adoption rejection and all registered IDs.
  • backend/domain/canonical/canonical_test.go: golden artifact-ID assertions.
  • backend/domain/canonical/testdata/golden_vectors.json: append 15 identity vectors; retain all original 18 positive / 15 negative vectors unchanged.
  • backend/domain/canonical/testdata/verify_golden.py: independent prefix/ID verification, preserving encoding/digest rules.
  • scripts/check-input-artifact-contract.go: identity succeeds; minimal probe and 5 relabelled supported examples remain rejected by the unchanged C1 schema. Preserve 5 positive, 46 negative and 14 D-04 checks.
  • docs/canonical-encoding-contract.md: whitelist and identity-only compatibility boundary.
  • docs/input-artifact-contract.md: current D-01 implementation status; separate C0 minimal identity and C1-C full-body acceptance.

Independent minimal identity probe (deliberately incomplete, not a usable ReadSet):

{ "schema_version": "1.0", "context_revocation_epoch": 0, "artifact_type": "read_set_snapshot" }

Expected canonical UTF-8 bytes:

{"artifact_type":"read_set_snapshot","context_revocation_epoch":0,"schema_version":"1.0"}

Digest: 5fad4b2ab6f44260174c65a2f5478b6e8402059e18ef33ce709ed866b2fb5824.

ID: rset_5fad4b2ab6f44260174c65a2f5478b6e8402059e18ef33ce709ed866b2fb5824.

Expected bytes were explicit literals; Python hashlib.sha256(b"magi:canonical:v1:read_set_snapshot\n" + canonical_bytes) generated expectations independently of Go. Both implementations reproduce them. Additional identical-body vectors freeze all 14 registered types, including the 13 pre-C0-R identities.

C. RED→GREEN

Before production registration (using the literal type to obtain a behavioral failure rather than an undefined-constant compile error):

TestCanonicalGoldenVectors/identity_read_set_snapshot: unknown_type
TestCanonicalGoldenVectors/read_set_snapshot_minimal_identity: unknown_type
TestReadSetSnapshotIdentity/registered_type_and_prefix: read_set_snapshot must be a registered C0 type
TestReadSetSnapshotIdentity/same_body_different_types: unknown_type
TestReadSetSnapshotIdentity/equivalent_encodings_same_identity: unknown_type
TestReadSetSnapshotIdentity/authoritative_field_changes_digest: unknown_type
TestRegisteredArtifactIDsAreByteFrozen/read_set_snapshot: unknown_type
C1-A checker: D-01 C0 identity type is not registered

The 13 old identity regressions and 18 old positive golden vectors already passed in RED. Unknown-type and non-canonical adoption rejection were existing invariants that stayed green. After appending the constant/map entry, tests use TypeReadSetSnapshot; the same focused suite and checker pass.

Additional negative controls (temporary fixtures, no repository schema/vector corruption): changing the expected rset ID makes the Python CI verifier fail; adding a schema branch accepting ReadSet makes the C1-A checker fail with D-01 identity-only ReadSet probe accepted as a C1 input artifact. The unchanged fixtures pass.

D. 验证

All commands below passed from backend/ using the writable cache:

go test ./domain/canonical ./domain/validation ./domain/execution ./application/a2a
go test -race ./...
go vet ./...
gofmt -l .   # no output
python3 domain/canonical/testdata/verify_golden.py domain/canonical/testdata/golden_vectors.json  # OK (0 failures)
go run ../scripts/check-input-artifact-contract.go

Also passed: gofmt -l scripts/check-input-artifact-contract.go, git diff --check, unchanged-vector/schema audit, and explicit -count=1 -v runs of both named legacy freezes. Local full race does not activate MySQL-gated tests; real MySQL validation is supplied by the two dedicated CI jobs.

Named compatibility tests: TestCanonicalGoldenVectors, TestGoldenVectorsReproduceInPython, TestRegisteredArtifactIDsAreByteFrozen (14 types), TestLegacyManifestDigestsAreByteFrozen (legacy-manifest/v1, legacy-approval-intent/v1) and TestLegacyA2ARequestHashIsByteFrozen.

All 6/6 CI jobs in .github/workflows/ci.yml passed on the exact Head above. CI run 39872320461. Backend step results separately confirm race tests, vet, Python cross-language vectors and the C1-A checker succeeded; both real MySQL jobs passed.

CI job Result
Runtime conformance SUCCESS
MySQL migration compatibility SUCCESS
Operational scripts gate SUCCESS
Frontend quality gate SUCCESS
Backend quality gate SUCCESS
Decision writer cutover (MySQL) SUCCESS

E. Findings

Read-only reviewer found no actionable defects; independently reran the Python gate, canonical package tests, C1-A checker and whitespace check. No old test constant, schema, historical digest or legacy data changed.

Local baseline initially could not write the default Go cache; all actual test evidence uses writable GOCACHE=/tmp/magi-c0r-go-cache. That setup failure is not the behavioral RED.

F. 放行

Draft for review only. C0 identity registration is implemented; formal ReadSet issuance/publication/voting remains unavailable. Registration does not let old consumers accept the new type. Producers must remain disabled until complete consumer validation and explicit capability negotiation pass.

Not implemented or claimed: ReadSetJournal, full ReadSet schema/semantic validator, full-body Golden/closure, database tables, FSM/Agent Loop/RAG/context/recovery changes, SealedBallot/BallotSet changes, AuthorityProof, runtime revocation/concurrency/production switch verification, C1-B or decision-artifact v2 work. No Issue closure, CAS-9 Done, Ready conversion or merge. Full body semantics/Golden are C1-C, and authority integration remains blocked by its stated contracts and C2.

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