Repository navigation
feat(core): Run aggregate, HiveJournal and the section 9 agent loop - #41
Merged
Merged
Conversation
6 tasks
Use the primary-constructor form for the private constructor and make the Hive boxes private. Flush the sequence counter before writing the step record so a crash cannot reuse a seq, and cover the durability path and the denied/finished branches with tests.
Run exposes taints through an unmodifiable live view and accepts new labels only through addTaint. CancelToken.child() derives a token that inherits the parent's cancellation while cancelling independently, so one tool call can be abandoned without cancelling the run.
Add the application/agent seams (RunResult, ToolSet/ToolRegistry, AgentConfig, ApprovalService, ContextBuilder, AgentDeps), the fail-closed defaults, and runAgent. The loop journals policy denials and executed calls, runs tools concurrently on child cancel tokens, and ends in RunCompleted or RunBudgetExceeded. Export the new types from the package.
Register the agent defaults and AgentDeps in the core module and add registerJournal, which opens a HiveJournal under a caller-supplied directory and registers it as both HiveJournal and JournalPort. Regenerate the injectable config and cover the bindings, the fail-closed defaults and the duplicate-registration guards.
Rewrite the M2 plan to the plan template with the completed steps ticked, record Q7-Q14 in the open-questions list, and add the section 9 implementation pointer to domain.md.
Dimoshka
marked this pull request as ready for review
November 8, 2026 09:29
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
M2 groundwork for the
Runaggregate, the Hive-backed journal, and the section 9 agent loop. This PR turns the draft step 1 into the full verified batch: the domain and loop seams are in place, fail-closed defaults are bound in DI, and the discrepancies found against the spec are recorded as open questions.What landed
Run aggregate and cancellation
Run.taintsis a live read-only view over labels copied from the constructor argument;Run.addTaintis the only way to add a label, and it is idempotent. The run itself never removes one.CancelToken.child()derives a token that inherits the parent's cancellation while cancelling independently, so one tool call can be abandoned without cancelling the run.HiveJournal
new _form (fixesunnecessary_type_name_in_constructor); the Hive boxes are private.seqcounter is flushed before the step record, so a crash cannot reuse a sequence number; a skippedseqis harmless.startedcalls, reopen durability, denied records, andfinishedon an unknown seq.Section 9 agent loop
application/agent/seams:RunResult,ToolSet/ToolRegistry,AgentConfig,ApprovalService,ContextBuilder,AgentDeps, and internaltruncateToolOutput.runAgentfollows the fixed section 9 order: malformed/unavailable checks, policy, approval, journalstartedbefore the call, timeout on a per-invocation child token, taint on untrusted output, non-throwing truncation, a fresh tool snapshot per step, and cancellation re-checks.DefaultAgentConfigkeeps declared risk,DenyAllApprovalsrefuses,EmptyToolRegistry,PromptContextBuilderstarts from the prompt.package:alteri_one_core.DI
AgentDepsis bound lazily inCoreModule, so startup stays green without anLlmPortand only resolution fails (providers arrive in M3).registerJournal({required String directory})opens the journal afterconfigureCore, registers it as bothHiveJournalandJournalPort, and rejects a duplicate registration before opening any box.configureCorestays synchronous and I/O-free.injection.config.dartregenerated.Docs
docs/plan/M2.mdrewritten to the plan template with completed steps ticked.docs/spec/open-questions.md.docs/spec/domain.mdsection 9; no decision was changed.Verification
melos run cigreen (format, analyze, arch check, tests).dart run tools/docs_check/bin/docs_check.dart: exit 0.dart run tools/codegen_check/bin/codegen_check.dart: exit 0;melos run genproduces no diff.Deliberate deviations (open questions Q7-Q14)
Runvs copy-with for taints — read-only view plusaddTaint._truncateUntrustedcontract — UTF-8 bytes, rune-safe cut,jsonEncodefor non-strings, bounded fallback, no section 13 wrapper in M2.d.config/d.registry/d.context/d.approvals— minimal application-layer interfaces.registerJournal(directory:), no home-directory default.maxSteps—maxStepsonly until providers report usage.failed(section 9), with a per-invocation child token.Explicitly NOT in this PR
chatmode end-to-end against a fakeLlmPort.runAgenttoRunBloc/StatePublisherand projects journal state.Closes #42