Skip to content

feat(harness): freeze recorded continuation inputs [SAP-3292] - #1006

Closed
ynadge wants to merge 1 commit into
dormant-terminal-activationfrom
assistant-continuation-brief
Closed

ynadge wants to merge 1 commit into
dormant-terminal-activationfrom
assistant-continuation-brief

Conversation

@ynadge

@ynadge ynadge commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Primary change type

  • Feature

Problem and motivation

Recorded Continue needs a fixed public reconstruction and one child-owned accepted context across retries. Resolving guidance again after a lost acceptance acknowledgement could silently change the prepared child.

Summary and scope

Build a bounded brief with exact record provenance, omissions and incomplete-work warnings. Add acceptFrozen to the existing delivery coordinator: validate and detach the full candidate before authority IO, reuse the receipt-owned acceptance ID, and retain through the existing authoritative source store. Composition and recovery still require the original accepted material.

Related work

Related issue: https://linear.app/sapiom/issue/SAP-3292

Depends on #1005. Native stack target: main. Receipt/native protocol and UI follow separately; this is a shared primitive, not a runtime activation change.

Validation

pnpm --filter @sapiom/harness exec vitest run src/core/assistant-continuation-brief.test.ts src/core/studio-assistant-delivery.test.ts src/core/assistant-source-store.test.ts src/core/assistant-sources.test.ts src/server/studio-assistant.test.ts src/server/opencode.test.ts — 131 passed
pnpm --filter @sapiom/harness exec tsc --noEmit — passed
pnpm --filter @sapiom/harness build:server — passed
Scoped ESLint and git diff --check — passed
Frozen-input and authority guard mutations — failed as expected, restored

Tests and documentation

Covers brief bounds and provenance, immutable retries after process restart/lost acknowledgement, changed guidance, candidate mutation during authority IO, conflicting acceptance identity, and retained-source composition. Added assistant-continuation.md. Increment is 764 changed lines including tests/docs/changeset; pr:size is absent.

Compatibility and release impact

  • Breaking or externally visible changes: additive internal delivery method; ordinary Send behavior preserved.
  • Changeset: added for @sapiom/harness.
  • Fix-forward: correct frozen acceptance validation through the same source owner while preserving existing receipts and accepted content.

Security

  • No secrets, credentials, private data, or unsanitized logs included.
  • No suspected vulnerability disclosed publicly.

AI assistance

  • AI assistance used: Codex implemented the brief and delivery extension; root reviewed input/authority boundaries and reran focused tests, typecheck, build and lint.

Checklist

  • CONTRIBUTING.md read; maintainer-authorized issue work.
  • One focused increment, tests, relevant checks, documentation, and release impact addressed above.
  • I can explain and maintain the submitted changes.

Devin Review

@coderabbitai

coderabbitai Bot commented Sep 14, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 6bd1b467-a0d2-4021-8bd7-5b3b33c8acdf

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

Devin Review

Comment on lines +84 to +92
turns[0] = clamp(
turns[0]!,
Math.max(
1,
RESUME_BRIEF_DEFAULT_MAX_TOKENS * 4 -
(text.length - turns[0]!.length) -
40,
),
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Oversized turn loses latest context

For an oversized final turn, clamp keeps its oldest prefix and drops the newest messages. The child receives stale context instead of the turn's latest state.

Learn more

A turn renders its user message first and assistant messages afterward. The budget fallback clamps that complete rendered string from the right, so overflow removes the most recent assistant messages first. This conflicts with the earlier turn-level policy, which deliberately retains recent context for continuation. The truncation marker reveals that some text vanished but does not preserve the state needed to continue.

Example: A single turn contains a short user task followed by 30 assistant updates. If the rendered turn exceeds 6,000 estimated tokens, the brief keeps the task and early updates while dropping update 30, which describes the current work.

Recommended fix: Bound oversized turns structurally. Preserve the turn header and user prompt, then retain assistant messages or parts newest-first within the remaining budget. Add an explicit count or marker for omitted messages and test that the final assistant message survives.

Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@ynadge ynadge closed this Sep 15, 2026
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