Repository navigation
feat(kernel): compose generated history codecs and CID links - #2660
Conversation
Add fixed-profile DAG-CBOR CID primitives, generator leaf support, and canonical encoding and allocation qualification. Keep history codecs unchanged. Co-authored-by: Mecatl <[email protected]>
Generate persistence and value methods in the packages that own resource IDs, content IDs, history IDs, commits, and records. Share operation accounting, canonical encoding, transactional decoding, and explicit local validation across package boundaries, including bootstrap from missing or broken output. Migrate history to shared codec helpers and exact-byte content verification. Remove handwritten history serialization, redundant CID and policy wrappers, and named-limit machinery. Update dependency guards, API snapshots, references, and regression coverage for ownership, canonicality, and resource admission. Co-authored-by: Mecatl <[email protected]>
Remove obsolete format codec/CID release notes and redundant parser tests from the former owner package, retaining identity-owner coverage and the independent history composition checks. Rename stale decoder tests and correct struct-only root diagnostics. Reject uint shadowing before generation so emitted machine-maximum field caps cannot silently resolve to an owner-defined narrow integer type. Add regression coverage and post-backend history read cancellation checks. Co-authored-by: Mecatl <[email protected]>
Approved implementation plan: history-codecs
The full current plan follows without omissions. Its delivery-checkpoint amendment Phase 2: compositional generated history codecsSlug: history-codecs Joe explicitly chose the existing branch instead of Delivery checkpoint — 2026-11-03Implementation is complete. Joe subsequently authorized a combined final-tree Combined-review corrections preserve the settled contract: remove obsolete Outcome and settled scopeGenerate the actual history persistence DTOs and all persisted named dependencies Settled with Joe:
No history bytes have been persisted. Byte-identical old history encodings/CIDs, Existing boundaries to change
Public operation and ownership contractGenerate these five methods on each persisted named type (aliases use the func (v T) CheckCBOR(b *codec.Budget, depth, fieldMax int) error
func (v T) AppendCBOR(dst []byte) []byte
func (v *T) ReadCBOR(r *codec.Reader, depth, fieldMax int) error
func (v T) Clone() T
func (v T) Equal(other T) boolShared runtime interfaces Whole-value helpers construct state and validate all positive global limits once. Encode checks the entire value before output/sorting allocation, then appends ReadCBOR reads one nested value into a fresh temporary and assigns its receiver All unsupported-type, recursion, inaccessible-owner, malformed tag and method Declarations and semantic compositionUse the existing source-local go:generate registry and one marked output per Proposed concrete declaration grammar for this slice: //cborgen:validate validateCBOR
// ID is a validated resource identifier.
type ID struct {
value string `cbor:",value" cborlimit:"bytes=25"`
}
//cborgen:validate validateCBOR
// HistoryID identifies one history.
type HistoryID struct {
value resourceid.ID `cbor:",value"`
}
//cborgen:validate validateCBOR
// CID is a fixed-profile content identity.
type CID struct {
binary [36]byte `cbor:",cid"`
}The annotation belongs to the named type declaration and names a local value
Owner validators run after the relevant generated structural/budget traversal Generation and identity dependency graphDesired imports: codec -> stdlib/Atmos only; engine/id -> codec; Cross-package generation must bootstrap when all selected generated files are History migrationCommit keeps format version/sequence/records and uses optional Delete the handwritten cborDecoder, append/sizing helpers, CID facade/parser, Backend remains opaque. Derive ByteReadRequest.MaxCommitBytes directly from API compatibility: no production/wire API major/feature change, since no shipped Dependency-ordered implementation tasks
Acceptance and verification
Focused commands: The integration owner runs task test once per integrated set; then PR-ready Final panel-review fixed point is the recorded phase-2 baseline Review and handoffFresh-context general, architecture and security design reviews completed against Keep the final plan ignored and update HANDOFF.md at Joe's explicit request before |
Summary
Compose generated persistence codecs across the isolated kernel's actual history DTOs and identity owners, including fixed-profile CID links. This is the combined final result of the CID-link and history-codec work following #2651; it does not activate the kernel in production.
codec.Check,Encode, andDecode[T]helpers.format.CID, format-specific limits/convenience functions, per-type codec entry points, and named-limit dictionaries. History hashes emitted bytes and verifies the original accepted bytes directly.Issue relationship
Closes #2662. Relates to #2659. This completes another infrastructure milestone, not the production-cutover outcome. Follows merged #2179, #2639, and #2651.
Type of change
Test plan
Baseline checks
task linttask --concurrency 3 test— full run passed again after the final diagnostic cleanuptask --concurrency 1 test:race— full rerun passed; the initial run hit the unchanged UI flake described belowgo run ./cmd/mecademo— demonstrated tool call/result and permission ask/approval/resulttask docstask site:build— not applicable; no user-docs/UI behavior changetask api:check; affected API snapshots were regenerated during implementation and remain currentengine/CHANGELOG.mdrecords additiveengine/idmethods; early-kernel contracts follow the scoped exemption from compatibility/changelog bookkeepingtask generateandtask generate:codecs:checkgit diff --checkThe initial full race run failed only in unchanged
TestStreamMarkdownMatchesFullRender/heading_and_fence_runs: incremental/fulloutput differed in ANSI token-run grouping, with no data-race report. Five
focused race repetitions passed, followed by a successful full race rerun with
module concurrency reduced to one. The same signature was observed during
earlier phase-2 qualification and is now tracked in #2661. Current main's newer
Chroma dependency is not a verified fix: focused comparisons passed on both old
and new versions. No UI or dependency-pin changes are included here.
Earlier implementation qualification also covered standalone engine/generator tests, focused architecture/history/identity race tests, 386 checks, allocation/resource admission, and bounded fuzz smokes. Those receipts are separate from the fresh PR-preparation gates above.
Changes
internal/cborgen/engine/kernel/codec/engine/id/,engine/kernel/contentid/,engine/kernel/history/id/engine/kernel/history/format/,engine/kernel/history/API compatibility
engine/id.ID. The experimental kernel intentionally replaces its initial codec APIs, removesformat.CIDand format-specific limits/convenience functions, and changes commit identities to optional pointers. Kernel consumers must use the new owner methods/shared helpers andcontentid.CID; the scoped experimental policy permits this without compatibility facades. API snapshots and both dependency guard sets are updated.User-facing change
None in the production harness. This is isolated-kernel infrastructure.
Special notes for reviewers
Reviewed the combined final tree against
0dde05a06c484d31cafca9c838dd2f1ad17dc35a, not just the second commit. Spec, Standards, independent Test adequacy, and architecture/security/reuse/duplication reviews are clear after targeted fixes and rechecks.The combined review removed obsolete facade release notes, deleted a redundant CID parser suite stranded in the former format owner while retaining owner-level coverage, and renamed stale decoder tests. It also found and fixed owner
uintshadowing of generated machine-maximum caps (regression demonstrated failing before the fix and passing afterward), and added late backend-return cancellation coverage with positive controls.No squash or rebase was performed. The PR description describes the final combined design; intermediate commit descriptions describe their original scopes.
Full approved implementation plan and delivery-checkpoint amendment, archived in one conversation comment and verified by full-content SHA-256 readback. Planned checks in that archive are distinct from executed results above.