Skip to content

feat(agent-harness): deliver legacy history and project durable text - #5659

Open
iscekic wants to merge 1 commit into
shared-agent-harness-3bb0-s6from
shared-agent-harness-3bb0-s7
Open

feat(agent-harness): deliver legacy history and project durable text#5659
iscekic wants to merge 1 commit into
shared-agent-harness-3bb0-s6from
shared-agent-harness-3bb0-s7

Conversation

@iscekic

@iscekic iscekic commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Summary

No new behavior — this change prepares chat history transfer without connecting it to the live product.


The public createQuickChatRuntime adapter uses QuickChatAuthoritySchema and QuickChatAuthority to enforce primary-database authority without creating threads or registry rows.
Leased legacy delivery uses ClaimSchema (QuickChatClaim) to preserve retries; projections use ProjectionSchema (QuickChatProjection) to deduplicate text and prevent import loops.
QuickChatAuthorityError rejects mutations against missing, mismatched, or retired authority; callers must supply the primary database.

Files
  • packages/db/src/quick-chat-runtime.ts — adds lookupThread, claimPending, withClaim, and projectText. 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, and created_at/id ordering 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, and z.iso.datetime() timestamps; defaults clientId to null. Inserts provenance: 'harness', server_projection_key, and ingress_acknowledged_at together 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-runtime without adding dependencies or changing existing exports.

The drainLegacyHistory contract accepts a HistorySource and LegacyHistoryImporter, and validates a matching DurableImportReceipt with DurableImportReceiptSchema before acknowledgment.
LegacyHistoryImport keeps authority separate from historical text, while HistoryDelivery reports acknowledged, retry, or rejected without 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 through LegacyMessageSchema, discarding attached authority even for assistant text. Requires a strict receipt with durable: true and matching messageId, threadId, userId, organizationId, and generation. Reports retry for importer, receipt, acknowledgment, or lease failures, and rejection for QuickChatAuthorityError. 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

  • before merge: Run the 33 PostgreSQL cases in continuous integration (CI).
  • before merge: Verify the completed stack tip on the backend, browser, iOS, and Android.
  • before merge: Merge the stack from the lowest level upward after the section passes its completion gate.

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.

  1. shared-agent-harness-3bb0chore(agent-harness): register workspaces and enforce CI boundaries #5632
  2. shared-agent-harness-3bb0-s2feat(agent-harness): define portable domain and snapshots #5637
  3. shared-agent-harness-3bb0-s3feat(agent-harness): define commands tools and permission policy #5639
  4. shared-agent-harness-3bb0-s4feat(agent-harness): share client state and cursor recovery #5643
  5. shared-agent-harness-3bb0-s5feat(agent-harness): persist command intents and execution receipts #5647
  6. shared-agent-harness-3bb0-s6feat(db): add harness ingress grants and retirement fences #5655
  7. shared-agent-harness-3bb0-s7feat(agent-harness): deliver legacy history and project durable text #5659 ← this PR
  8. shared-agent-harness-3bb0-s8feat(agent-harness): authorize durable grants and registered clients #5662
  9. shared-agent-harness-3bb0-s9feat(agent-harness): fence retirement and retry payload cleanup #5667
  10. shared-agent-harness-3bb0-s10feat(agent-harness): persist authoritative state in SQLite #5675
  11. shared-agent-harness-3bb0-s11feat(agent-harness): admit durable runs and revisioned commands #5678
  12. shared-agent-harness-3bb0-s12feat(agent-harness): recover queued runs and stream checkpointed steps #5688
  13. shared-agent-harness-3bb0-s13feat(agent-harness): resolve interactions and dispatch tools sequentially #5693 (tip)

@kilo-code-bot

kilo-code-bot Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (4 files)
  • apps/web/src/lib/agent-harness/history.test.ts
  • apps/web/src/lib/agent-harness/history.ts
  • packages/db/package.json
  • packages/db/src/quick-chat-runtime.ts

Reviewed by grok-4.6 · Input: 117.1K · Output: 33K · Cached: 900.9K

Review guidance: REVIEW.md from base branch shared-agent-harness-3bb0-s6

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