feat(agent): add engine-neutral model-turn journal contract #337
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.43) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 395 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.358
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #337"
general
weight: 0.35
yuluo-yx
This pr implements the engine-neutral journal neutral contract and shared implementation. so maintainers can review whether the plan is appropriate.
Since I see that many follow-up tasks depend on this task, I am concerned that there may be aspects of the design here that I have not fully considered.
Relate to #125
Scope
| Module | Changes |
|---|---|
|
argi-agent-core| Adds theagent.durablepackage withModelTurnRecorder,ModelTurnCodec, stable journal identity types, recovery policy types, documentation, and reference tests. |Design
1. Separate journal preparation from storage coordination
ModelTurnRecorderis stateless. It prepares immutable journal entries and validates replay.ModelTurnCodechandles versioned payloads, request fingerprints, canonical tool arguments, and tool-definition fingerprints.RunStore.commit, leases, revisions, checkpoints, and snapshot updates.2. Use stable logical identities
Callers provide
Turn(runId, turnId)and restore the same identity during recovery.Tool plans are identified by their logical turn and response ordinal within the run. Provider-generated tool-call IDs and model attempt numbers do not change task identity.
Request fingerprints, model-call reservations, terminal responses, and tool plans are journaled. Request bodies are not persisted. Messages, generation options, and disclosed tool definitions participate in the request fingerprint.
3. Persist before invoking or dispatching
The reference execution sequence is:
A complete recorded result is replayed without another model call. Revision conflicts require reloading the snapshot and repeating replay before reserving another attempt.
4. Make recovery and re-asking explicit
Replay validates the run identity, request fingerprint, entry types and versions, and the complete tool-plan set. Inconsistent or incomplete records fail closed.
ModelTurnAttemptPolicy.DEFAULTusesFAIL_CLOSEDwith one total model-call reservation. Recovery re-asking is allowed only when the caller explicitly usesMissingResponsePolicy.REASK, and it remains bounded bymaxAttempts.Committed reservations survive interruption and recovery and are never refunded. Streaming deltas are diagnostic only and cannot authorize model or tool execution.
The policy is caller-owned and is not persisted in
RunSpecor the journal schema. The caller must keep the same policy for the logical run across recovery.Validation scope
Reference tests use the existing
MemoryRunStoreto simulate recovery within one process. Durable backend integration, execution-position recovery, tool receipts, and exactly-once execution remain runtime responsibilities and are outside this PR.Validation completed with:
All reactor modules passed.