Skip to content

feat(core): journal model calls and add chat end-to-end - #44

Merged
Dimoshka merged 1 commit into
mainfrom
feat/m2-chat-journaling
Nov 8, 2026
Merged

Dimoshka merged 1 commit into
mainfrom
feat/m2-chat-journaling

Conversation

@Dimoshka

@Dimoshka Dimoshka commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds ModelCall to the domain and two JournalPort methods (modelStarted, modelCallsForRun), so model calls are recorded before they happen (invariant 5).
  • HiveJournal gains a kind discriminator: model calls and tool invocations share one steps box and one seq counter.
  • Adds the JournalingLlm decorator, an application-layer LlmPort wrapper that journals each call and bounds error text before it is stored.
  • Introduces AgentDepsFactory.forRun(RunId) and replaces the agentDeps DI binding with it.
  • Adds four chat end-to-end tests, journaling_llm_test.dart, hive_journal_test.dart coverage, and the matching domain/storage/plan/doc updates.

Decision

ADR-0012 (resolving open question Q13): model-call journaling lives in an application-layer LlmPort decorator, applied per run through AgentDepsFactory.forRun. The section 9 agent loop itself stays journal-free — it keeps receiving an LlmPort and does not learn about RunId or the journal. Transcript persistence also belongs in this decorator but is deferred to plan Step 8.

Review notes

Deliberate non-goals, reported during review but not fixed in this PR:

  • DI bypass enforcement: AgentDeps keeps its public primary constructor, and getIt<LlmPort>() still returns the raw provider. Structurally preventing a bypass (private constructor, @visibleForTesting, non-default Hive instanceName) is deferred.
  • _nextSeq has no write lock: the monotonic seq under concurrency currently relies on a hive_ce implementation detail.
  • No unified seq-ordered recordsForRun; tool invocations and model calls are read through separate methods.
  • _writeStarted is duplicated between the tool and model paths in HiveJournal.
  • FakeJournal.modelStarts / modelRecords are currently unused by tests.
  • ADR-0012 status is left Accepted although the ADR is not yet merged.

Test evidence

  • melos run ci: SUCCESS — 230 tests passed.
  • arch_check: OK (no forbidden imports).
  • docs_check: OK.
  • Codegen is idempotent (no diff after melos run gen).

Refs #43

- Add the ModelCall record and two JournalPort methods: modelStarted and
  modelCallsForRun.
- Add a kind discriminator to HiveJournal records so model calls and tool
  invocations share one seq counter and one steps box.
- Add the JournalingLlm application-layer LlmPort decorator; error text is
  bounded before it reaches the journal.
- Replace the agentDeps DI binding with AgentDepsFactory.forRun, which wraps
  the raw provider per run.
- Add four chat end-to-end tests covering the journaled model call.
- Add ADR-0012, resolving open question Q13; the section 9 loop stays
  journal-free.
- Update domain, storage, forbidden-glossary and plan docs, the package
  export and the injection tests.

Refs #43
@Dimoshka
Dimoshka merged commit 606f825 into main Nov 8, 2026
1 check passed
@Dimoshka
Dimoshka deleted the feat/m2-chat-journaling branch November 8, 2026 12:13
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