Repository navigation
feat(kernel): retain reusable context and rich content facts - #2725
Conversation
Preserve ordered authored messages separately from prepared content with semantic purpose and provenance. Add independent session-scoped instruction, tool catalog, and model binding replacements with immutable selected views. Extend shared admission and replay validation, exact frozen retries, and closeout-reserve coverage while keeping production entry points unchanged. Publish the current implementation for review; the requested simplification of experimental format versioning remains a separate pending review fix. Co-authored-by: Mecatl <[email protected]>
Kernel context implementation planSlug: kernel-context. Source: Amendment: adds the approved explicit user-input naming, pinned identity lookup, recursive immutable views, field-only byte copies, vocabulary/documentation, and completed verification. Supersedes the prior completed-batch archive; deferred streaming/codegen and all isolation boundaries remain. Kernel context — review polish and recursive inspectionSlug: kernel-context Status and authorityJoe authorized implementation, then explicitly requested commit/push, PR update, At batch start the tracked tree was clean; local HEAD, exact remote branch and PR Goal and unchanged boundariesMake public names, persisted vocabulary/documentation and accepted-state inspection Preserve the existing passive isolated kernel: one UserInput submission with Parts, Grounded seams at batch start (historical)
All paths above are relative to engine/kernel/session/ unless explicitly qualified. Approved naming and lookup contract
func (v Snapshot) UserInputByID(id UserInputID) (UserInputView, bool)Return zero,false for zero/invalid IDs, foreign history, absent run/input, and input Recursive read-only inspection contract
Vocabulary and schema documentationIntroduce named constants for closed persisted vocabularies: ContentPart.Kind, Improve member Godoc throughout session/format, including lifecycle facts as needed: Keep ModelBinding.Route, documented as a logical provider/route name interpreted Dependency-ordered tasks and checks
Lead owns aggregate gates, workers focused checks only. Run task generate, The new public inspection surface warrants fresh final-tree panel review against Implemented verification resultsAll approved tasks are complete. Generation/codecs/API checks, full offline tests Compatibility, publication and resumeExperimental isolated Go API changes only; Joe explicitly approved renamed/removed Existing PR plan comment: No material open product decisions remain. Concrete accessor/constant spelling, |
Flatten authored submissions and media, retain run-owned attributed increments with whole-input references, and remove experimental version compatibility scaffolding. Preserve bounded ownership, ordered admission, replay and retry invariants. Co-authored-by: Mecatl <[email protected]>
Use explicit user-input contracts and snapshot-pinned identity lookup. Replace bulk accepted-value exports with recursive views, retain owned byte-field copies, and document persistence vocabulary and ownership. Co-authored-by: Mecatl <[email protected]>
Move media classification into Media, make text/media branch presence explicit, and preserve detached storage and bounded immutable inspection. Co-authored-by: Mecatl <[email protected]>
Co-authored-by: Mecatl <[email protected]>
Keep the implemented DTO, validation, ownership, and view contracts beside their code rather than duplicating them in a pending-design note. Co-authored-by: Mecatl <[email protected]>
Retain indexed access while adding repeatable, pinned iter.Seq traversal for content, instructions, effective input, tools, records, and runs. Cover public admission seams, concurrent readers, allocation axes, and opaque consumer overhead. Co-authored-by: Mecatl <[email protected]>
Summary
Adds passive, durable, reusable context/content facts to the isolated kernel.
UserInput{ID UserInputID, Parts}with ordered text/media parts and exact metadata, inline bytes, remote URI, or complete provider/scope/reference binding.EffectiveInput{RunID, Inputs}. Each item references a whole earlier same-run user submission or supplies inline parts with an exact logical Actor, semantic Purpose, and Source provenance. Empty/inline-only batches and duplicates are legal; no consumption, deduplication, fallback, or per-input replacement semantics.Part of #2663 and parent #2659; does not complete either issue. No production integration, model/tool lifecycle, request preparation, provider-role mapping, blob store, or execution. Kernel contracts remain provisional as higher layers develop.
Latest review batch
Implemented in
b40c45289e8f7bbec8d1826f50896b8e735c2021:UserInputID,UserInputView,AddUserInputRequest, andAddUserInput. Keep generic input-item/effective-input names.InstructionBlock.Partsin domain and persistence types without changing serialized field meaning or payload version 1.Snapshot.UserInputByID(UserInputID) (UserInputView, bool), using existing ordinal locators in O(1). Full identity and pinned membership checks reject foreign, invalid, absent, extreme, and later-than-snapshot identities without narrowing overflow. Empty inputs and interrupted historical runs remain readable. Remove positional/count user-input methods fromRunView; retain chronological records.Value/DTOFormat/parts-slice inspection with recursive immutable, type-owned views. Compound children use views, collections use count/index navigation, and union branches expose presence. Zero handles are safe except indexed access outside bounds, which panics.Earlier review batches flattened content/media and replaced per-input effective revisions with incremental whole-submission references. Full-scope checks precede scope omission; earlier same-batch references are legal, forward references are not. Structural validation, canonical decoding, resource limits, retry, reserve, and atomicity are preserved.
Suggested review order
engine/kernel/session/format/declarations, field contracts, and local validators; skip generated codec bulk initially.session/user_input_id.go,user_input.go,session_commit.go, andsnapshot.go: naming, ownership, identity lookup, and pinned selections.content_part.go,media.go,content_source.go,input_item.go,attributed_input.go: recursive navigation and explicit branches.effective_input.go,instructions.go,tool_catalog.go,tool_definition.go, andmodel_binding.go: context handles and field-only byte exports.lifecycle_state.go,session.go,value_budget.go, andrecord.go: admission, staged publication, scope checks, and bounds.Verification
Passed locally for this batch:
task generate,task generate:codecs:check,task api:update,task api:checktask test,task test:race,task test:engine-standalonetask lint,task docs,git diff --checkgo run ./cmd/mecademo: Read result and Write permission ask/approval/result observed.GOWORK=off; session/format/architectureGOARCH=386.Fresh final-tree review against
841f554c0392dce842604faa22e4c7035438a208covered Spec, Standards, independent Test adequacy, and Domain architecture/security/reuse/duplication. One Standards finding (construction-field Godoc) and one Reuse advisory (redundant manual index guards) were fixed. Targeted Standards/Test/Security/Reuse rechecks are clean; unaffected axes retain their initial scoped evidence. No remaining findings or reviewer failures.Full test/race suites began during review. After final comment/native-index cleanup, codec/API checks, focused normal/standalone race and 386 checks, and full lint passed again. Reviewers inspected the supplied current dirty/new-source candidate; ignored captures were unavailable under child workspace authority. The directing agent retained and compared exact source snapshots; no claim that children independently verified archive hashes.
API compatibility
Only isolated experimental Go/domain/persistence contracts change. Joe explicitly approved renamed/removed Go APIs and recursive navigation. There is no persisted experimental data; payload version 1 remains without compatibility-only machinery. No production/wire/protobuf/client change, major/feature bump, module-pin change, history-envelope change, or codec-runtime redesign. Structural safety remains. The early-kernel exception skips changelog bookkeeping, not regenerated API snapshots/codecs.
Full current implementation plan and review amendments, archived in the existing marked PR conversation comment with exact-body readback and plan-digest verification.