feat(agent-harness): deliver legacy history and project durable text - #5659
Open
iscekic wants to merge 1 commit into
Open
feat(agent-harness): deliver legacy history and project durable text#5659iscekic wants to merge 1 commit into
iscekic wants to merge 1 commit into
Conversation
This was referenced Aug 28, 2026
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (4 files)
Reviewed by grok-4.6 · Input: 117.1K · Output: 33K · Cached: 900.9K Review guidance: REVIEW.md from base branch |
This was referenced Aug 28, 2026
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
No new behavior — this change prepares chat history transfer without connecting it to the live product.
The public
createQuickChatRuntimeadapter usesQuickChatAuthoritySchemaandQuickChatAuthorityto enforce primary-database authority without creating threads or registry rows.Leased legacy delivery uses
ClaimSchema(QuickChatClaim) to preserve retries; projections useProjectionSchema(QuickChatProjection) to deduplicate text and prevent import loops.QuickChatAuthorityErrorrejects mutations against missing, mismatched, or retired authority; callers must supply the primary database.Files
packages/db/src/quick-chat-runtime.ts— addslookupThread,claimPending,withClaim, andprojectText. Checks the live thread, unblocked owner, undeleted organization, matching registry, generation, and retirement fence. Preserves arbitrary user identifiers and null personal scope; normalizes universally unique identifiers (UUIDs) to lowercase. Lookup returns null for inactive authority; explicitly scoped claims reject it. Claims 1–50 pending legacy rows (default 50) with 60-second leases,SKIP LOCKED, andcreated_at/idordering instead of a timestamp watermark. Holds authority locks through import and rechecks authority plus the active lease before recording acknowledgment and clearing the lease. Validates strict user/assistant projections, a nonempty key, andz.iso.datetime()timestamps; defaultsclientIdto null. Insertsprovenance: 'harness',server_projection_key, andingress_acknowledged_attogether to prevent import loops. Handles both UUID and projection-key conflicts, accepting only matching identity, thread, role, text, client identifier, provenance, delivery state, and normalized timestamp.packages/db/package.json— exposes@kilocode/db/quick-chat-runtimewithout adding dependencies or changing existing exports.The
drainLegacyHistorycontract accepts aHistorySourceandLegacyHistoryImporter, and validates a matchingDurableImportReceiptwithDurableImportReceiptSchemabefore acknowledgment.LegacyHistoryImportkeeps authority separate from historical text, whileHistoryDeliveryreportsacknowledged,retry, orrejectedwithout granting execution rights.The importer must commit UUID deduplication and text before returning
durable: true; this adapter does not implement SQLite persistence or compose the runtime.Files
apps/web/src/lib/agent-harness/history.ts— adds a sequential, bounded drain for one authority or all registered conversations, suitable for request or cron callers. Preserves the legacy message UUID, role, text, client identifier, and timestamp; normalizes timestamps to Coordinated Universal Time (UTC). Parses only historical message fields throughLegacyMessageSchema, discarding attached authority even for assistant text. Requires a strict receipt withdurable: trueand matchingmessageId,threadId,userId,organizationId, andgeneration. Reports retry for importer, receipt, acknowledgment, or lease failures, and rejection forQuickChatAuthorityError. Keeps the text-only compatibility path until old append writers and historical records are gone.Tests: 1 test file added —
apps/web/src/lib/agent-harness/history.test.ts(+755 lines).Generated: 0 files changed.
Verification
No manual runtime verification ran for this level because the runtime is not composed and the durable importer remains injectable.
Visual Changes
Visual Changes: N/A
Reviewer Notes
Human steps
This level adds no new environment values, secrets, migrations, or flags that require setup.
Automated checks
The handoff reports seven scoped checks and 17 pure tests passed. The 33 PostgreSQL cases did not run locally.
Notes
No manual runtime verification ran for this level. Full backend, browser, iOS, and Android verification remains required on the completed stack tip.
The 33 PostgreSQL cases remain required in CI. Injected importer tests prove adapter ordering, not durable SQLite import.
Stacked PRs — merge bottom to top. Each level shows only its own diff.
Runtime verification (E2E, user advocacy, simplify) runs on the tip PR over every level.
Every level keeps its own checks, its own bot review, and its own threads; each one is answered on its own PR.
Each level is its own deliverable: it builds and passes its own checks alone.
A finding on a level is repaired on that level, then carried upward with stack.sh forward.
shared-agent-harness-3bb0— chore(agent-harness): register workspaces and enforce CI boundaries #5632shared-agent-harness-3bb0-s2— feat(agent-harness): define portable domain and snapshots #5637shared-agent-harness-3bb0-s3— feat(agent-harness): define commands tools and permission policy #5639shared-agent-harness-3bb0-s4— feat(agent-harness): share client state and cursor recovery #5643shared-agent-harness-3bb0-s5— feat(agent-harness): persist command intents and execution receipts #5647shared-agent-harness-3bb0-s6— feat(db): add harness ingress grants and retirement fences #5655shared-agent-harness-3bb0-s7— feat(agent-harness): deliver legacy history and project durable text #5659 ← this PRshared-agent-harness-3bb0-s8— feat(agent-harness): authorize durable grants and registered clients #5662shared-agent-harness-3bb0-s9— feat(agent-harness): fence retirement and retry payload cleanup #5667shared-agent-harness-3bb0-s10— feat(agent-harness): persist authoritative state in SQLite #5675shared-agent-harness-3bb0-s11— feat(agent-harness): admit durable runs and revisioned commands #5678shared-agent-harness-3bb0-s12— feat(agent-harness): recover queued runs and stream checkpointed steps #5688shared-agent-harness-3bb0-s13— feat(agent-harness): resolve interactions and dispatch tools sequentially #5693 (tip)