Repository navigation
feat(kernel): generate immutable payload views with layered dtogen - #2749
Conversation
Evolve cborgen into independent DTO generation capabilities, add borrowed containers, and adopt canonical payload-backed session views. Preserve scoped adapters and bounded persistence behavior. Co-authored-by: Mecatl <[email protected]>
Design rationaleOne payload model; explicit destination scope
Nested numeric references intentionally have destination-run meaning. Extracting a component from another run does not preserve its origin: it may resolve to an eligible occurrence in the destination run. Membership and ordering are still checked there. Full public occurrence IDs retain parent scope for equality and correlation; reconstructing one neither allocates nor establishes membership. Mechanical getters; explicit contextual navigationThe DTO owns default field policy, while the consuming view owns enclosing identity context. Automatically constructed children must be context-free. Required, optional, and collection children that need scope use handwritten navigation rather than receiving incomplete identities. Handwritten collection adapters may capture immutable enclosing context; that construction can allocate and is measured separately from traversal. Borrowed inspection; explicit exportAccepted backing is privately owned and immutable. Nested views retain it without copying siblings; byte Bounded validation; checked installationPublic composite DTO validation checks complete child contracts without imposing resource policy. Codec traversal applies bounds before allocation and invokes immediate validation hooks rather than repeating recursive validation. Generator loading never executes owner code. Rendering and typechecking precede installation, but atomic file replacements are not a multi-file transaction; a filesystem failure can require regeneration. |
Review outcomeFinal implementation review covered Spec, Standards, Test adequacy, Architecture, Security, Library reuse, and Duplication. The final review reported no remaining blockers, important findings, or advisories. Review and regression coverage includes canonical payload/view adoption; exact scoped identities through Submit and storage-backed Load; zero, presence, borrowing, and leaf-copy contracts; and generator selection, owner loading, and artifact protections. Allocation checks cover populated Media variants and distinguish captured-adapter construction and iterator escape from direct traversal. Verification is scoped by revision in the PR description.
|
Use canonical session DTOs with explicit destination scope, validated occurrence-ID reconstruction, and source-tagged generation across all payload views. Preserve bounded admission, immutable borrowing, and canonical storage bytes. Co-authored-by: Mecatl <[email protected]>
Select DTO and view roots beside their declarations with dtogen include markers while preserving explicit-list support and load-only validation. Generate plain media leaf getters and use scoped SliceView collections for effective inputs, with separate coverage for closure allocation costs. Co-authored-by: Mecatl <[email protected]>
Co-authored-by: Mecatl <[email protected]>
Summary
Generate immutable DTO-backed views and consolidate session authoring around canonical
session/formatpayloads in the isolated kernel. No production integration.dtogenindependently generates CBOR, Clone, Equal, and view accessors from a shared typed graph. It loads owners without executing their code, renders and typechecks the selected closure before installation, and protects deterministic generated artifacts.//dtogen:includemarkers select roots. DTOviewtags define omitted or handwritten fields; safe untagged fields generate getters. Scope-bearing child navigation stays handwritten.views.Byteswith explicit leaf-onlyCopy; collections useviews.SliceViewwithout materializing intermediate view slices. Zero and optional views preserve absence versus present-empty values.Closes #2747. Relates to #2663.
Review navigation
internal/dtogen/engine/kernel/views/engine/kernel/session/format/engine/kernel/session/engine/api/Verification
The implementation at
c2b93c83fpassedtask test,task test:race,task lint,task docs, DTO generation/freshness and API snapshot checks, plus the offline demo exercising a tool call, permission approval, and result. Final generator-selection regressions also passed the focused dtogen race suite.The documentation-only head
db5b932aapassedtask generate:data,task generate:data:check,task docs, andgit diff --check; regeneration changed no artifacts. Full code suites were not rerun for that documentation-only delta.Submit and storage-backed Load tests cover complete nested traversal, scoped identities, zero/presence behavior, retained snapshots, and leaf-only copying with nonempty siblings. Allocation checks distinguish context-free traversal from captured-adapter construction and iterator escape costs; scoped collection construction is not claimed to be allocation-free.
API compatibility
This is an unwired experimental kernel Go API change, approved during review: canonical payload aliases, explicit-destination commit signatures, zero-only synthesized authoring fields, relative nested references, recursive public validation, occurrence-ID reconstruction, and borrowed/container inspection accessors. In-tree callers and API snapshots are updated.
No production wire/client/SDK behavior, protobuf contract, wire major or feature identifier, runtime entry point, module dependency pin, persistence schema/version, or canonical stored bytes changes. No client/server or stored-data upgrade is required. Production integration remains a separate change.