Skip to content

feat(core): 1.AA chat regression harness — complete 1.m5 agent-first sub-spine#31

Merged
cemililik merged 7 commits into
mainfrom
development
Jun 17, 2026
Merged

feat(core): 1.AA chat regression harness — complete 1.m5 agent-first sub-spine#31
cemililik merged 7 commits into
mainfrom
development

Conversation

@cemililik

@cemililik cemililik commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

What

Completes the Phase-1 Lane C agent-first sub-spine by landing the 1.AA Node-harness chat regression and updating the roadmap to mark 1.m5 complete.

This PR merges the development branch since PR #30, so it also carries the already-reviewed-and-merged post-PR#30 hardening commits for 1.Y/1.Z and the documentation-only ADR-0041 / action-guard-seam.md proposal.

1.AA deliverable

  • New end-to-end Node harness: packages/core/src/engine/m5-chat-harness.e2e.test.ts
    • Multi-turn AgentSession chat with a tool round-trip.
    • session:* event stream over RunEventBus via createSessionEventSink / createSessionHandle (1.W).
    • Resume from persisted transcript with reconstructSessionState + AgentSession.resume (1.Y).
    • Export-to-workflow round-trip with sessionToWorkflow + serializeWorkflow + parseWorkflow (1.Z).
    • Determinism check: identical event signature on re-run.
  • Roadmap status updates: 1.AA and 1.m5 marked complete in phase-1-engine-and-llm.md and current.md.

Scope

  • Package: @relavium/core (new e2e harness)
  • Docs: docs/roadmap/
  • Phase/workstream: Phase 1 · 1.AA / 1.m5

Checklist

  • Conventional Commits, one scope per commit, Refs: ADR-NNNN
  • pnpm turbo run lint typecheck test build green
  • pnpm format:check green
  • No vendor SDK type crosses the @relavium/llm seam
  • No platform-specific import in packages/core
  • No new runtime dependency
  • No secret in logs/events/IPC/exported YAML
  • Specs cited from docs/reference/, not restated

Refs: ADR-0024, ADR-0026

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • Documentation

    • Updated the Phase 1 roadmap/status to reflect completion of session checkpoint/resume and export-to-workflow, and marked the chat regression harness as done.
    • Added Proposed documentation for an optional action-governance “ActionGuard” seam, including an ADR and a reference contract for governing side-effecting tool execution.
  • Tests

    • Added an end-to-end regression test suite for the chat harness covering multi-turn sessions, workflow export/serialization, session transcript resumption, and determinism.

cemililik and others added 4 commits June 17, 2026 16:32
Session checkpoint/resume (1.Y) + export-to-workflow (1.Z) merged via PR #30. Mark both ✅
Done across the status surfaces (phase-1 matrix rows + §1.Y/§1.Z landed notes, current.md,
CLAUDE.md, README.md). Lane C (1.m5) now has only the 1.AA chat-regression harness left;
also fixed a stray ◇ on the already-Done 1.V matrix row.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Introduced the `ActionGuard` interface to govern side-effecting tools and egress actions.
- Defined a two-phase protocol for decision-making and committing actions, including compensation handling.
- Established the `ActionIntent`, `ActionDecision`, and supporting types for structured interaction with the guard.
- Ensured compliance with existing policies and mechanisms, maintaining local-first guarantees and idempotency.
- Documented the integration points and lifecycle within the tool registry dispatch process.
Implements the 1.m5 Node harness: multi-turn AgentSession chat with a
tool round-trip, session:* event stream over RunEventBus, resume from
persisted transcript, and export-to-workflow round-trip. Mirrors the
1.U harness patterns (scriptedProvider, echo registry, deterministic
clock, canonical schema + gap-free sequence assertions).

Refs: ADR-0024, ADR-0026

Co-Authored-By: Claude <noreply@anthropic.com>
Update phase-1-engine-and-llm.md and current.md now that the 1.AA
chat-regression harness has landed on the development branch, closing
the Lane C agent-first sub-spine milestone.

Refs: ADR-0024, ADR-0026

Co-Authored-By: Claude <noreply@anthropic.com>

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @cemililik, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: cc9667d0-ee0c-42a2-821b-a8488337b92a

📥 Commits

Reviewing files that changed from the base of the PR and between 04bf9dc and 8bd9a8a.

📒 Files selected for processing (2)
  • docs/decisions/0041-external-action-governance-seam.md
  • packages/core/src/engine/m5-chat-harness.e2e.test.ts
✅ Files skipped from review due to trivial changes (1)
  • docs/decisions/0041-external-action-governance-seam.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/core/src/engine/m5-chat-harness.e2e.test.ts

📝 Walkthrough

Walkthrough

Marks Phase 1 Lane C items 1.Y (session checkpoint/resume), 1.Z (export-to-workflow), and 1.AA (chat regression harness) as complete across all roadmap and status documents. Adds the concrete 1.AA regression test (m5-chat-harness.e2e.test.ts) covering multi-turn chat, workflow export round-trip, session resume, and determinism. Introduces ADR-0041 and a reference document proposing an optional host-injected ActionGuard seam over side-effecting tool execution.

Changes

Phase 1 Sub-spine Completion (1.AA Harness + Roadmap)

Layer / File(s) Summary
Harness stubs, tool registry, and session wiring
packages/core/src/engine/m5-chat-harness.e2e.test.ts
Defines scriptedProvider deterministic LLM stubs, in-memory echoRegistry, fixed AGENT/CONTEXT/TS constants, and harness utilities (createBus, buildSession, drainSession, schema/sequenceNumber assertion helpers).
Multi-turn chat and determinism regression tests
packages/core/src/engine/m5-chat-harness.e2e.test.ts
e2e test asserting lifecycle event shape, tool call/result presence, streamed tokens, monotonic cost events, gap-free sequenceNumbers, schema canonicality via RunOrSessionEventSchema; determinism test verifying identical event signatures and token sequences across independent runs.
Workflow export round-trip and session resume tests
packages/core/src/engine/m5-chat-harness.e2e.test.ts
Export test: sessionToWorkflowserializeWorkflowparseWorkflowserializeWorkflow byte-stable YAML, node/edge/metadata validation. Resume test: reconstructSessionState + AgentSession.resume asserts prior transcript included in provider input; session:started not re-emitted.
Roadmap and status doc updates (1.Y/1.Z/1.AA/1.m5)
CLAUDE.md, README.md, docs/roadmap/current.md, docs/roadmap/phases/phase-1-engine-and-llm.md
Marks 1.Y/1.Z/1.AA Done (PR #30), 1.m5 complete with ✅, Lane C dependency matrix updated; only multimodal sub-spine (1.AE–1.AH) remains before Phase 2.

ActionGuard Seam Proposal (ADR-0041 + Reference)

Layer / File(s) Summary
ADR-0041: motivation, decision, and composition model
docs/decisions/0041-external-action-governance-seam.md, docs/decisions/README.md
New ADR (Proposed/DRAFT) covering motivation (transactional safety, information-flow control, delegation-aware authorization, audit), core decision (optional ActionGuard at ToolRegistry dispatch after ADR-0029 guardrails, verdict union semantics, host mechanism responsibilities), end-to-end verdict flow diagram, rejected alternatives, and consequences. ADR index updated with entry 0041.
Reference: ActionGuard interface, intent, verdict, and plan types
docs/reference/shared-core/action-guard-seam.md
Canonical reference defining ActionGuard interface (decide/commit/compensate), ActionCommit thunk, ActionIntent payload (taint, secretArgKeys, ActionPrincipal, ActionCorrelation), ActionClass set, and ActionDecision verdict union (allow/block/require-approval/transform) with ActionPlan/ApprovalRequest structures.
Reference: lifecycle, composition rules, determinism, scope, and error taxonomy
docs/reference/shared-core/action-guard-seam.md, docs/reference/shared-core/README.md
Dispatch lifecycle insertion point, composition constraints (off-by-default, after-never-replaces, narrow-only transform, taint/secret handoff), determinism/replay/idempotency rules via ActionReceipt keying, run-vs-session scope (approval and saga-unwind run-only), error taxonomy mapped to tool-registry error codes, and createToolRegistry({ actionGuard? }) instantiation example. Shared Core README table updated with draft entry.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • HodeTech/Relavium#30: The M5 harness e2e test directly exercises the session checkpoint/resume (1.Y) and export-to-workflow (1.Z) behavior delivered in PR #30, and all roadmap updates reference PR #30 as the landing vehicle for those items.
  • HodeTech/Relavium#29: The harness test exercises session transcript export and resume from persisted state, building on the session/message persistence contracts established in PR #29.

Poem

🐇 Hop, hop—the lanes are done!
1.Y, 1.Z, 1.AA — every one! ✅
The session resumes, the workflow exports clean,
The harness runs twice to prove what tests mean.
An ActionGuard waits at the side-effect door,
Proposed but not wired — just drafted in lore.
Phase 2 is unblocked, let the next sprint begin! 🚀

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately captures the main deliverable (1.AA chat regression harness) and its significance (completing 1.m5 agent-first sub-spine), aligning with the PR's primary objective of introducing the new test harness and marking the milestone complete.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch development

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request documents the proposed ADR-0041 for an external action-governance seam (ActionGuard) and adds the 1.AA chat-regression harness (m5-chat-harness.e2e.test.ts) to verify the agent-first sub-spine end-to-end. It also updates various roadmap and status documents to reflect the completion of milestones 1.Y, 1.Z, and 1.AA. A review comment points out a missing set of properties (agentSnapshot and title) in the session record mock within the new test file, which could cause strict type-checking failures.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +387 to +397
{
id: 'sess-aa-resume',
agentSlug: AGENT.id,
context: CONTEXT,
status: 'idle',
totalInputTokens: 10,
totalOutputTokens: 5,
totalCostMicrocents: 2100,
createdAt: TS,
updatedAt: TS,
},

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The object passed to reconstructSessionState is missing the agentSnapshot and title properties, which are required by the AgentSessionRecord type (as seen in the record fixture defined on line 270). Lacking these properties can cause TypeScript compilation errors when strict type checking is enabled. Adding them ensures full type safety and alignment with the AgentSessionRecord schema.

      {
        id: 'sess-aa-resume',
        agentSlug: AGENT.id,
        agentSnapshot: AGENT,
        title: 'Chat Resume',
        context: CONTEXT,
        status: 'idle',
        totalInputTokens: 10,
        totalOutputTokens: 5,
        totalCostMicrocents: 2100,
        createdAt: TS,
        updatedAt: TS,
      },

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@CLAUDE.md`:
- Line 41: The opening status paragraph in CLAUDE.md incorrectly states that
Lane C is still waiting on the 1.AA harness completion, but the current repo
state marks 1.AA/1.m5 as complete. Update the status text to remove or revise
the statement indicating 1.AA is pending, and ensure the opening paragraph
reflects that 1.AA (the chat-regression harness / 1.m5 multimodal sub-spine) is
now done. Additionally, update the compact checklist at lines 66-67 to align
with this completed state so the roadmap documentation matches the actual
repository progress.

In `@docs/decisions/0041-external-action-governance-seam.md`:
- Around line 51-53: The decision text claims to govern all side-effecting
tools, but the bullet points only explicitly mention process-spawn, egress, and
fs-write. The `outputStore` write path exposed via the `ToolHost` interface is
not listed and can therefore bypass governance. Either add `outputStore` to the
explicit list of governed side-effecting tools in the decision bullets, or
narrow and clarify the scope statement to accurately reflect which write paths
are actually covered by the governance seam.

In `@docs/reference/shared-core/action-guard-seam.md`:
- Around line 164-172: The OpaqueGuardState type definition currently uses
Readonly<Record<string, unknown>> which admits non-serializable values and
breaks persistence/replay functionality since these fields are journaled.
Replace the OpaqueGuardState type definition to constrain it to
JSON-serializable data only, such as a union of serializable primitives and
nested objects, or use a branded type that explicitly enforces serializable
constraints. This ensures only values that can be safely journaled and replayed
are allowed in the opaque guard state.
- Around line 123-127: The `block` verdict in the `ActionDecision` type
currently uses a free-form `reason: string` field, which doesn't align with the
existing denial taxonomy and can leak policy details. Replace the `reason:
string` with the stable reason codes from the `ToolPolicyError` taxonomy or the
`ActionDeniedError` classification system that is introduced in the table at
lines 244-249. This ensures consistency with the actual `tool_denied` denial
path and prevents arbitrary text from appearing in logs and audit trails.

In `@docs/roadmap/phases/phase-1-engine-and-llm.md`:
- Around line 37-40: The opening summary paragraph contains a status statement
about Lane C that conflicts with other parts of the document. Specifically, the
paragraph states that Lane C is "leaving only the 1.AA harness" as remaining
work, but the 1.AA block and milestones table elsewhere in the document already
mark 1.AA as done. Update the opening summary paragraph to reflect that Lane C
(including the 1.AA harness) is complete, making it consistent with the later
sections of the roadmap document.

In `@README.md`:
- Around line 54-56: The README milestone summary in the Phase-1 engine critical
path section currently lists "1.AA harness" as remaining work, but this PR
completes that component. Update this section to remove 1.AA harness from the
list of remaining work and add it to the completed items with a checkmark in the
same format as the other completed phases (session events 1.W ✅, persistence 1.X
✅, session checkpoint/resume 1.Y & export-to-workflow 1.Z ✅), and update the
Phase-2 status statement to reflect that 1.AA harness is now complete so the
public milestone summary matches the actual finished state.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d9e92129-318e-4274-9a2d-8ba464007085

📥 Commits

Reviewing files that changed from the base of the PR and between 2cf9480 and 4a94730.

📒 Files selected for processing (9)
  • CLAUDE.md
  • README.md
  • docs/decisions/0041-external-action-governance-seam.md
  • docs/decisions/README.md
  • docs/reference/shared-core/README.md
  • docs/reference/shared-core/action-guard-seam.md
  • docs/roadmap/current.md
  • docs/roadmap/phases/phase-1-engine-and-llm.md
  • packages/core/src/engine/m5-chat-harness.e2e.test.ts

Comment thread CLAUDE.md
Comment thread docs/reference/shared-core/action-guard-seam.md
Comment thread docs/reference/shared-core/action-guard-seam.md Outdated
Comment thread docs/roadmap/phases/phase-1-engine-and-llm.md
Comment thread README.md
- CLAUDE.md, README.md, phase-1-engine-and-llm.md: mark Lane C / 1.m5
  complete now that the 1.AA chat-regression harness is landed.
- action-guard-seam.md: constrain OpaqueGuardState to JSON-serializable
  values (it is journaled for replay/resume) and use ToolPolicyDenyReason
  for the block verdict instead of a free-form string.
- Skip ADR-0041 outputStore bullet and m5-chat-harness record fields:
  ADRs are append-only per project rules; agentSnapshot/title are optional
  in AgentSessionRecord.

Refs: ADR-0024, ADR-0026, ADR-0041

Co-Authored-By: Claude <noreply@anthropic.com>
@cemililik

Copy link
Copy Markdown
Contributor Author

@coderabbitai review all

@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown

@cemililik Sure! I'll kick off a full review of all changes in PR #31 right away.

✅ Action performed

Full review finished.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
docs/decisions/0041-external-action-governance-seam.md (2)

54-54: 💤 Low value

Minor: Slightly awkward adverb placement on line 54.

The phrase "a resumed run never double-posts" reads naturally in context, but LanguageTool suggests "a resumed run will never double-post" for better standard order. This is a style nitpick, not a correctness issue.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/decisions/0041-external-action-governance-seam.md` at line 54, Change
the phrase "a resumed run never double-posts" to "a resumed run will never
double-post" in the deterministic replay section to improve grammatical flow and
follow standard verb tense conventions.

Source: Linters/SAST tools


106-106: 💤 Low value

Minor: Consider a synonym for the overused "exactly".

Line 106 uses "exactly what" to describe the governor's dry-run + compensation. LanguageTool flags this as repetitive phrasing. An alternative like "precisely" or a rephrase ("what the governor's own dry-run + compensation makes safe") could improve readability.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/decisions/0041-external-action-governance-seam.md` at line 106, The
phrase "exactly what" on line 106 is flagged as repetitive phrasing that impacts
readability. Replace "exactly what the governor's own dry-run + compensation
makes safe" with a synonym or rephrase to improve clarity, such as using
"precisely what" instead of "exactly what" or restructuring the sentence as
"what the governor's own dry-run + compensation makes safe" to eliminate the
redundancy while maintaining the intended meaning.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/decisions/0041-external-action-governance-seam.md`:
- Around line 51-53: The ADR document lists governed side-effecting operations
(process-spawn, egress, fs-write) but does not explicitly address whether
`outputStore`, a host-injected write mechanism, is governed by the ActionGuard
or is an out-of-scope host detail. To resolve this ambiguity before ADR-0041 is
accepted, either add `outputStore` to the bullet point that begins with
"Side-effecting tools and egress" if it should be intercepted by the governor,
or expand the "Composes after, never replaces" bullet to explicitly clarify that
host-injected mechanisms like `outputStore` are orthogonal to the ActionGuard
seam, which governs only tool calls and not internal host execution paths.

In `@packages/core/src/engine/m5-chat-harness.e2e.test.ts`:
- Around line 104-118: The echoRegistry currently accepts any tool call in the
dispatch method without validating that the requested tool is actually 'echo',
which can mask regressions where unexpected tool calls are emitted. Add a guard
condition in the dispatch method to check if the tool being called (accessed via
call.name) matches exactly 'echo', and throw an error or reject the promise if
it does not match. This ensures the test fails fast when an unexpected tool is
invoked, rather than silently accepting it.

---

Nitpick comments:
In `@docs/decisions/0041-external-action-governance-seam.md`:
- Line 54: Change the phrase "a resumed run never double-posts" to "a resumed
run will never double-post" in the deterministic replay section to improve
grammatical flow and follow standard verb tense conventions.
- Line 106: The phrase "exactly what" on line 106 is flagged as repetitive
phrasing that impacts readability. Replace "exactly what the governor's own
dry-run + compensation makes safe" with a synonym or rephrase to improve
clarity, such as using "precisely what" instead of "exactly what" or
restructuring the sentence as "what the governor's own dry-run + compensation
makes safe" to eliminate the redundancy while maintaining the intended meaning.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ed571ba8-9207-48ab-97be-9b98c7c7b58a

📥 Commits

Reviewing files that changed from the base of the PR and between 2cf9480 and 04bf9dc.

📒 Files selected for processing (9)
  • CLAUDE.md
  • README.md
  • docs/decisions/0041-external-action-governance-seam.md
  • docs/decisions/README.md
  • docs/reference/shared-core/README.md
  • docs/reference/shared-core/action-guard-seam.md
  • docs/roadmap/current.md
  • docs/roadmap/phases/phase-1-engine-and-llm.md
  • packages/core/src/engine/m5-chat-harness.e2e.test.ts

Comment thread docs/decisions/0041-external-action-governance-seam.md
Comment thread packages/core/src/engine/m5-chat-harness.e2e.test.ts
cemililik and others added 2 commits June 17, 2026 17:48
Pre-acceptance refinements to the Proposed ADR:
- Add a composition rule noting that host-internal spill mechanisms such as
  outputStore are orthogonal to the ActionGuard seam (they are ToolHost
  bookkeeping, not tool calls).
- Minor wording improvements: 'never double-posts' → 'will never double-post',
  'exactly what' → 'precisely what'.

Refs: ADR-0041

Co-Authored-By: Claude <noreply@anthropic.com>
…ected tools

The harness stub now rejects any tool call whose name is not 'echo' and
only claims to have 'echo' in has(), so regressions that emit unintended
tool calls surface immediately rather than being masked by a permissive
stub.

Refs: ADR-0024, ADR-0026

Co-Authored-By: Claude <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@cemililik
cemililik merged commit bda9d49 into main Jun 17, 2026
9 checks passed
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