Skip to content

fix: reliably persist execution details for long conversations - #3782

Merged
integry merged 4 commits into
integry:mainfrom
czehentner:fix/execution-detail-persistence
Dec 1, 2026
Merged

integry merged 4 commits into
integry:mainfrom
czehentner:fix/execution-detail-persistence

Conversation

@czehentner

Copy link
Copy Markdown
Contributor

Summary

Long agent runs could end with a correct llm_executions summary row but zero llm_execution_details rows, so the conversation view was empty.

Root cause

Verified. processConversationLog() inserted the entire conversation in one db('llm_execution_details').insert(detailsArray). For SQLite, knex compiles a multi-row insert into a compound SELECT … UNION ALL …, which SQLite caps at 500 terms; the bound-variable limit is hit as well. Reproduced against better-sqlite3 + knex with a 14-column table:

rows result
50 ok
500 ok
501 too many terms in compound SELECT
5000 too many SQL variables

The execution row is inserted first, and persistToDatabase() caught the detail error, logged a generic message and still returned the row as persisted, leaving a summary without details.

SQLite persistence strategy

  • insertConversationDetails() writes in order in batches of 100 (14 columns → 1,400 variables, far below both limits), keeping the original sequence_number (the log index).
  • Each batch uses onConflict(['execution_id','sequence_number']).ignore(), relying on the existing unique index (no migration). Repeating the call stores only what is missing and never duplicates.
  • A failed insert is retried (3 attempts) before giving up.
  • Chosen over a single transaction: a transaction would drop all details on any failure, while idempotent batches keep the largest valid prefix and make a later repair safe. The execution row stays committed, so the LLM run is never repeated.
  • On final failure the row is kept, PersistedExecution.detailsPersisted is false, and an error is logged with the execution id and expected detail count ("execution row persisted but its conversation details are incomplete") instead of a generic persistence failure.
  • Empty or absent conversation logs insert nothing and are not errors.

Files changed

  • packages/core/src/utils/llmMetrics.ts
  • test/llmExecutionDetailPersistence.test.ts (new)
  • Existing test db mocks (llmMetricsRecording, llmMetricsClaimRecovery, llmMetricsFailedExecutions) gained onConflict().ignore().

Test coverage

Real SQLite (in-memory, real migrations): 50 / 500 / 5,000 events with order and sequence numbers verified; empty and absent logs; transient failure retried with no duplicates; persistent failure (a trigger) leaves a gap-free prefix and logs incomplete details; repeated inserts do not duplicate; 2,000-row direct insert. Existing llmMetrics* suites still pass; tsc and eslint src/ are clean.

Limitations

  • After all retries fail, the details stay partial until something repeats the insert; there is no automatic background repair, and a later recordLLMMetrics for the same execution id still skips the row as already persisted.
  • recordLLMMetrics still returns void, so callers observe the failure through the error log only.

llm_execution_details was written with one multi-row insert of the whole
conversation. knex compiles that for SQLite to a compound SELECT, which is
capped at 500 terms (and the bound variables are capped too), so runs of
more than 500 events failed after the execution row was already stored,
leaving a valid summary with zero details.

Insert in batches of 100 in sequence order, skipping rows already stored
under (execution_id, sequence_number) so a repeat never duplicates, and
retry a failed insert before giving up. When details still cannot be fully
stored, the execution row is kept and the failure is logged as incomplete
details instead of a clean success. No schema change or LLM re-run.

Co-authored-by: Copilot <[email protected]>
@czehentner
czehentner marked this pull request as draft November 24, 2026 09:29
@integry integry added the AI label Nov 24, 2026
@integry

integry commented Nov 24, 2026

Copy link
Copy Markdown
Owner

/review astra fable

@propr-dev

propr-dev Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

✅ AI Code Review Complete requested by @integry

Posted 2 reviews:

View Task Details

@propr-dev

propr-dev Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

🔍 AI Code Review — astra

Overall Evaluation

This PR needs minor changes before merge. The normal recording path addresses the SQLite statement limit and preserves completed batches. The remaining issues are localized to the batch-size override, the retry budget, and one claim-recovery test.

✅ Ordered, idempotent persistence — The recording path writes 100 rows at a time, preserves each event’s original log index, and uses the existing (execution_id, sequence_number) unique constraint to skip rows already stored.

✅ Diagnosable partial failures — When detail persistence throws after the summary row commits, the error log includes the execution ID and expected detail count. The real-SQLite test exercises this path with a trigger and checks the surviving sequence numbers.

Merge blockers

Every finding below was introduced by this PR and must be resolved before merging.

F1: 🔴 Remove the unchecked batch-size override

  • Category: complexity

  • Required behavior: The objective specifies batches of 100. The exported helper adds an unrequested option that bypasses that bound.

  • Evidence: packages/core/src/utils/llmMetrics.ts, insertConversationDetails; test/llmExecutionDetailPersistence.test.ts, final 2,000-row test.

    static trace:

    1. A caller can pass 2,000 details and batchSize = 2000 to the exported helper.
    2. The first slice contains all 2,000 rows. Knex submits them in one compound statement, exceeding the 500-term SQLite limit that motivated the change.
    3. The test named “whatever the batch size asked for” passes only details, so it exercises the safe default. Every supplied caller also uses the default.
  • Minimum fix: Remove the batchSize parameter, use DETAIL_INSERT_BATCH_SIZE for both the stride and slice width, and rename the direct-insert test to describe its fixed-batch behavior.

F2: 🔴 Give each failed insert its retry budget

  • Category: correctness

  • Required behavior: A failed insert gets three attempts before detail persistence gives up.

  • Evidence: packages/core/src/utils/llmMetrics.ts, insertDetailsWithRetry and insertConversationDetails.

    static trace:

    1. For a 300-event log, suppose each of the three batch inserts fails on its first submission and would succeed on its second.
    2. Attempt one stops at the first batch. Attempt two commits the first batch and stops at the second. Attempt three replays the first batch, commits the second, and reaches the third batch for the first time.
    3. The third batch’s first failure exhausts the conversation-wide budget. Persistence logs incomplete details and leaves events 200–299 missing. Conflict-ignore protects the committed prefix, but the third batch never receives a retry. The transient-failure test injects an error in only one batch.
  • Minimum fix: Put the three-attempt loop around the current batch’s insert and advance after it succeeds. Cover transient failures in three distinct batches of one conversation.

F3: 🔴 Restore exhausted-failure claim coverage

  • Category: tests

  • Required behavior: The existing claim-recovery test should still verify that a committed summary stays recorded after detail persistence ultimately fails.

  • Evidence: test/llmMetricsClaimRecovery.test.ts, a row whose details fail to insert still counts as recorded; test/llmExecutionDetailPersistence.test.ts, persistent-failure test.

    static trace:

    1. The claim-recovery test sets failNext.detailsInsert = 1. The first insert rejects and the new retry succeeds.
    2. The second call therefore exercises deduplication after successful detail persistence. Its assertions would still pass if the recorder incorrectly released the row claim only after exhausting retries.
    3. The SQLite trigger test reaches exhaustion, but its execution has no executionId and therefore no keyed claim. Together the tests leave the previously covered claim-retention case unchecked.
  • Minimum fix: Make the claim-recovery fixture fail all three attempts and assert that llm:metrics:persisted:details-fail remains claimed before the second record call. Keep the existing execution and counter assertions.

Suggestions

These are optional follow-ups and are not sent to /fix.

S1: 🟢 Assert the exact surviving prefix

The trigger rejects sequence 250, so the two completed 100-row batches should leave exactly 200 rows. The current assertion accepts any nonempty contiguous prefix shorter than 600. Checking for 200 rows would also catch loss of a previously committed batch. This is optional because the test already checks prefix ordering and the incomplete-detail diagnostic.

Score

The fixed-size recording path and SQLite coverage address the original long-run failure. The retry scope, unchecked override, and weakened claim test need localized corrections. All three current-head checks were skipped.

Score: 6/10


🤖 Review Details

  • Model: GPT-6.2 Astra
  • Time: 33s
  • Tokens: 46,936 (45,802 in / 1,134 out)
  • Cost: $0.31

View Task


💡 Next step: Comment /fix to address every F# merge blocker, /fix all for every pending blocker and suggestion, or name records explicitly, as in /fix F3 S5.
F# and S# IDs increment across review comments and remain permanent, so selectors such as /fix F3 F5 stay unambiguous across cycles. S# suggestions stay optional: they are implemented only when you name them or request /fix all, and they never relax a merge blocker.

Copy and edit to choose records from this review:

/fix F1 F2 F3 S1

🤖 Review by ProPR

@propr-dev

propr-dev Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

🔍 AI Code Review — fable

Overall Evaluation

The PR fixes a real, well-diagnosed defect: one multi-row insert of the whole conversation exceeds SQLite's compound-SELECT and bound-variable limits, leaving a summary row with no details. The fix is batched, idempotent inserts with a bounded retry and a distinct "details incomplete" error, and it matches the stated objective. The persistence logic traces correctly through recordLLMMetrics → persistToDatabase → processConversationLog.

It needs one small change before merge: the additions appear to push packages/core/src/utils/llmMetrics.ts over the core package's max-lines lint gate (F1). I could not run anything in this review, and no test or lint check ran on the current head (all three checks are skipped), so nothing in CI confirms or refutes this.

✅ Idempotent batches on the existing unique index — insertConversationDetails uses onConflict(['execution_id','sequence_number']).ignore() against the table.unique([...]) already in the initial migration. No migration is needed, and only that constraint is ignored; foreign-key and NOT NULL errors still surface.

✅ Retries cannot drift or duplicate — detailsArray is built once before insertDetailsWithRetry, so every attempt sends identical rows, including the new Date() timestamp fallback.

✅ Real-SQLite coverage of the actual limit — test/llmExecutionDetailPersistence.test.ts runs real migrations on in-memory better-sqlite3 at 50/500/5,000 rows. It also forces a mid-run failure with a trigger and asserts a gap-free prefix plus the specific error log.

Merge blockers

Every finding below was introduced by this PR and must be resolved before merging.

F4: 🔴 llmMetrics.ts exceeds the core max-lines lint gate

  • Category: style

  • Required behavior: The repository's zero-warning lint gate for packages/core/src, which caps a file at 400 code lines (blank and comment lines excluded).

  • Evidence: packages/core/src/utils/llmMetrics.ts:194-223 (new batching and retry helpers) and packages/core/src/utils/llmMetrics.ts:305-311 (split error branch)

    Static trace (line count over the supplied full file, not executed):

    1. The head file is 501 lines; excluding blank and comment-only lines I count about 424 code lines.
    2. The diff adds about 24 net code lines to this file: 18 in the new helper block and 6 in the catch branch.
    3. That puts the base file at about 400 code lines, exactly at the cap, which fits the file's many one-line functions.
    4. The head file is therefore about 24 code lines over, and the core lint step fails on max-lines.

    The PR description reports only eslint src/ as clean; that is the root src/ tree, which does not include packages/core/src. No lint or test check ran on the current head, so CI does not contradict this.

    Unverified assumptions: I applied the 400-code-line rule from prior knowledge of this repository's lint gates; the ESLint config was not in the supplied context, so a per-file override for this file is not excluded. The file itself contains no eslint-disable max-lines.

  • Minimum fix: Move DETAIL_INSERT_BATCH_SIZE, DETAIL_PERSIST_ATTEMPTS, insertConversationDetails and insertDetailsWithRetry into a small sibling module (for example packages/core/src/utils/llmMetricsDetailInsert.ts), import it from llmMetrics.ts, and update the test import. Then run the core package lint to confirm the file is at or below the cap; if the catch branch still leaves it over, collapse that to one logger.error with a conditional message.

Suggestions

These are optional follow-ups and are not sent to /fix.

S2: 🟢 Existing "details fail" test now passes via retry

In test/llmMetricsClaimRecovery.test.ts, the test "a row whose details fail to insert still counts as recorded" sets failNext.detailsInsert = 1. With three attempts the second one succeeds, so the test no longer reaches the final-failure path it names. Setting it to 3 would restore coverage of "row kept and row claim retained when details ultimately fail". This is optional because the new suite covers persistent failure keeping the row, though without an executionId, so not the claim.

S3: 🟢 Misleading test title and unused batchSize parameter

The test "batches are bounded below SQLite limits whatever the batch size asked for" never passes a batch size. insertConversationDetails(details, batchSize) does not clamp the value, so a caller passing 1,000 would hit the original failure. No caller or test uses the parameter; either drop it or rename the test to what it checks (a 2,000-row direct insert with the default).

S4: 🟢 detailsPersisted is never read

PersistedExecution.detailsPersisted is set in persistToDatabase, but recordLLMMetrics and checkTokenOutlier ignore it, so the failure is visible only in the error log. This matches the stated limitations; the field could be removed or wired into a repair path or metric later.

S5: 🟢 Immediate retry mostly helps non-deterministic failures

insertDetailsWithRetry retries immediately with no delay, and lock contention is already retried at the connection level. Deterministic failures, such as a constraint violation or a serialization error, will simply fail three times and re-send the earlier batches each time. A short backoff or retrying only from the failed batch would be cheaper, but the cost today is small.

S6: 🟢 Partial conversations look complete to readers

After a final failure, parseExecutionDetailsFromDb returns the stored prefix with no sign that it is truncated. A later change could expose the incomplete state, for example via a column or a count comparison, so the conversation view can label it.

Score

The persistence fix is correct and well tested against real SQLite, but the changed core file appears to exceed the package's max-lines lint gate, and no CI check ran on the head to show otherwise.

Score: 6/10


🤖 Review Details

  • Model: Claude Fable 5.2
  • Time: 1m 48s
  • Tokens: 71,202 (60,002 in / 11,200 out)
  • Cost: $1.05

View Task


💡 Next step: Comment /fix to address every F# merge blocker, /fix all for every pending blocker and suggestion, or name records explicitly, as in /fix F3 S5.
F# and S# IDs increment across review comments and remain permanent, so selectors such as /fix F3 F5 stay unambiguous across cycles. S# suggestions stay optional: they are implemented only when you name them or request /fix all, and they never relax a merge blocker.

Copy and edit to choose records from this review:

/fix F4 S2 S3 S4 S5 S6

🤖 Review by ProPR

czehentner and others added 2 commits November 24, 2026 15:11
Keeps llmMetrics.ts within the 400-line max-lines lint gate.

Co-authored-by: Copilot <[email protected]>
Addresses review feedback on integry#3782:
- Retry budget is per batch, so later batches get their retries and
  committed batches are not re-sent (F2, S5).
- Drop the unchecked batchSize override; batches are always 100 rows (F1, S3).
- Claim-recovery test exhausts all attempts and asserts the row claim
  is retained (F3, S2).
- Persistent-failure test asserts exactly the 200-row prefix (S1).
- Remove the unread detailsPersisted field (S4).

Co-authored-by: Copilot <[email protected]>
@integry

integry commented Nov 24, 2026

Copy link
Copy Markdown
Owner

/review astra fable

@propr-dev

propr-dev Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

✅ AI Code Review Complete requested by @integry

Posted 2 reviews:

View Task Details

@propr-dev

propr-dev Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

🔍 AI Code Review — astra

Overall Evaluation

The PR needs one minor change before merge. Ordered batches address the SQLite statement limit, and a failed batch leaves earlier batches available for repair. The remaining gap is the promised detailsPersisted flag on the internal persistence result.

✅ Ordered, idempotent writes — The writer awaits each 100-row batch and uses the existing unique key on (execution_id, sequence_number). Replaying a batch preserves rows already stored for that execution.

✅ Real SQLite coverage — The new tests check event identity and sequence through 5,000 events. A trigger at sequence 250 also verifies that the first 200 rows survive a persistent failure and that replay can fill the missing rows.

Merge blockers

Every finding below was introduced by this PR and must be resolved before merging.

F5: 🔴 Return detail completion status

  • Category: requirement

  • Required behavior: The objective explicitly requires PersistedExecution.detailsPersisted to be false when the execution row commits but its conversation details remain incomplete.

  • Evidence: packages/core/src/utils/llmMetrics.ts:261, persistToDatabase

    static trace:

    1. After the summary insert succeeds, persisted contains only executionId and taskId.
    2. If a detail batch exhausts its three attempts, the catch block logs the execution ID and expected detail count.
    3. The function returns the same two-field object it returns after a successful detail write. Its caller can retain the row claim, but cannot distinguish the two outcomes from the result. The trigger test checks the stored prefix and error log, so it passes with the promised field absent.
  • Minimum fix: Add detailsPersisted: boolean to PersistedExecution. Initialize it to false when the row commits and set it to true after processConversationLog resolves, including for empty or absent logs. Keep the existing row-claim behavior and recordLLMMetrics return type.

Suggestions

These are optional follow-ups and are not sent to /fix.

S7: 🟢 Verify replay preserves existing content

The repair test supplies different metadata for the already-committed prefix, then checks only sequence numbers. Saving one prefix row before replay and comparing its content and metadata afterward would catch an accidental switch from conflict-ignore to conflict-update. This is optional because the current implementation explicitly uses .ignore() and the test already verifies gap filling and uniqueness.

Score

The batching logic and SQLite tests address the original data-loss case. All 14 current checks that ran passed, but the internal result still omits one explicit acceptance criterion.

Score: 6/10


🤖 Review Details

  • Model: GPT-6.2 Astra
  • Time: 32s
  • Tokens: 48,721 (47,941 in / 780 out)
  • Cost: $0.31

View Task


💡 Next step: Comment /fix to address every F# merge blocker, /fix all for every pending blocker and suggestion, or name records explicitly, as in /fix F3 S5.
F# and S# IDs increment across review comments and remain permanent, so selectors such as /fix F3 F5 stay unambiguous across cycles. S# suggestions stay optional: they are implemented only when you name them or request /fix all, and they never relax a merge blocker.

Copy and edit to choose records from this review:

/fix F5 S7

🤖 Review by ProPR

@propr-dev

propr-dev Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

🔍 AI Code Review — fable

Overall Evaluation

The PR fixes the verified root cause: a single multi-row insert of the whole conversation exceeded SQLite's compound-SELECT and bound-variable limits, leaving a summary row with no details. Details are now written in ordered batches of 100 with conflict-ignore on the existing unique index, and a failure after the execution row is committed is logged as incomplete details. The change is small, localized, and matches the stated strategy, with one exception: the description says PersistedExecution.detailsPersisted is false on final failure, but no such field exists in the diff (see S1). I found no merge blocker; the PR is ready to merge within scope.

This was a static review only; I ran nothing. The "Full Test Suite" shards were skipped on this head, so I could not confirm that no other suite mocks db(...).insert() without onConflict (see S5).

✅ Fix addresses the actual limit — packages/core/src/utils/llmMetricsDetails.ts slices into 100-row batches (1,400 bound variables, 100 compound terms), well under both limits, and keeps sequence_number as the log index, so the reader in liveDetailsCanonical.ts still sees the same ordering.

✅ Idempotent without a migration — onConflict(['execution_id','sequence_number']).ignore() relies on the table.unique(['execution_id', 'sequence_number']) constraint already in the initial schema. The repeat-insert test covers this on real SQLite.

✅ Tests exercise the real driver — test/llmExecutionDetailPersistence.test.ts runs better-sqlite3 with the real migrations at 50, 500 and 5,000 events. It uses a trigger to force a persistent mid-conversation failure and asserts the gap-free prefix and the specific error log entry.

Merge blockers

No merge blockers.

Suggestions

These are optional follow-ups and are not sent to /fix.

S8: 🟢 Description mentions a field that does not exist

The PR description says that on final failure "PersistedExecution.detailsPersisted is false". In packages/core/src/utils/llmMetrics.ts the interface is still { executionId; taskId }, and the outcome is signalled only by the new error log. Nothing reads such a field today and recordLLMMetrics returns void, so there is no behavioural gap. The description should be corrected, or the field added if a caller is expected to use it, so later readers do not look for a flag that is not there.

S9: 🟢 Retry is immediate and indiscriminate

insertBatchWithRetry retries any error three times with no delay. Lock contention is already replayed with asynchronous waits by installSqliteRetry (packages/core/src/db/sqliteRetry.ts). What reaches this loop is therefore mostly deterministic errors (binding, constraint or trigger failures), which will fail identically three times, or conditions that are unlikely to clear within microseconds. A short backoff, or skipping the retry for constraint/binding errors, would make the budget meaningful. This is optional because the objective asks for three attempts and the current behaviour is harmless.

S10: 🟢 Final error does not locate the failing batch

The "conversation details are incomplete" error logs executionId and detailCount, but not which batch failed or how many rows were stored. That information appears only in the preceding warn entries (firstSequence). Attaching the failing batch's first sequence to the thrown error or the final log would make a manual repair simpler.

S11: 🟢 Partial transcripts are indistinguishable to readers

Before this PR a detail failure left zero rows, so parseExecutionDetailsFromDb returned null and the consumer took its fallback path. Now a persistent mid-conversation failure leaves a prefix, which completedExecutionDetails returns as the completed transcript with no marker that it is truncated. This is the documented trade-off and needs an unusual persistent failure, so it is not a blocker. A persisted completeness marker (for example comparing the stored count with an expected count on the execution row) would let the UI flag it, and would enable the background repair listed under Limitations.

S12: 🟢 Confirm other db mocks support onConflict

Three suites' mocks were updated to return onConflict().ignore(). Any other suite that mocks connection.js and records a non-empty conversationLog would now hit a TypeError inside the retry loop. That would surface as an "incomplete details" error log rather than a thrown failure, so it could pass silently or break an errors assertion. Because the full shards were skipped on this head, a repository-wide search for such mocks, or one full-suite run, is worth doing before merge.

S13: 🟢 Minor cleanup

  • The info-level log titled "DEBUG: Sample detail before insert" was carried into the new module unchanged; it could be dropped to debug.
  • The JSDoc on persistToDatabase now has one very long line.
  • The transient-failure test rejects before any write, so it shows retry and logging but not replay after a partially applied batch. SQLite's statement atomicity makes this low-value to add.

Score

The fix is correct and well tested on the real driver, with no verified blocker and all current-head checks passing or skipped. The remaining items are a description mismatch and optional hardening.

Score: 8/10


🤖 Review Details

  • Model: Claude Fable 5.2
  • Time: 1m 4s
  • Tokens: 69,107 (63,541 in / 5,566 out)
  • Cost: $0.86

View Task


💡 Next step: Comment /fix to address every F# merge blocker, /fix all for every pending blocker and suggestion, or name records explicitly, as in /fix F3 S5.
F# and S# IDs increment across review comments and remain permanent, so selectors such as /fix F3 F5 stay unambiguous across cycles. S# suggestions stay optional: they are implemented only when you name them or request /fix all, and they never relax a merge blocker.

Copy and edit to choose records from this review:

/fix S8 S9 S10 S11 S12 S13

🤖 Review by ProPR

Repository owner deleted a comment from propr-dev Bot Nov 24, 2026
@integry

integry commented Nov 24, 2026

Copy link
Copy Markdown
Owner

/fix F5

@propr-dev

propr-dev Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

✅ Applied the requested follow-up changes in commit a149209

Addressed 1 AI review comment (IDs: 7136692407)

Addressed finding F5

Summary of Changes

Applied F5. persistToDatabase now returns detailsPersisted: false when the execution row commits but a detail batch exhausts its retries. It returns true after all batches finish, including for empty or absent logs. A committed row keeps its claim in either case, and recordLLMMetrics still returns Promise<void>.

All 39 focused persistence and metrics tests passed, including four new SQLite regressions that assert the returned status directly. Core typechecking and lint passed. The separate live Redis suite was stopped because Redis was unavailable.

Review digest

Risk-tiered paths

  • High risk: none
  • Normal risk (1 file)
    • packages/core/src/utils/llmMetrics.ts (+4/−3)
  • Low risk (1 file)
    • test/llmExecutionDetailPersistence.test.ts (+19/−1)

Diff size: 2 files changed, +23/−4 lines


🤖 Implementation Details

  • Model: GPT-6.2 Astra (medium)
  • Requested By: @integry
  • Time: 4m 17s
  • Tokens: 335,858 (334,381 in / 1,477 out)
  • Cost: $0.38

Undo Changes • View Task Execution


💡 ProPR Slash Commands
Command Description Example
/merge Merge target branch into this PR and resolve conflicts /merge
/review Request an AI code review /review or /review claude-sonnet
/fix Address review blockers, or blockers and suggestions with /fix all /fix, /fix all, or /fix F3 S5
/switch Change the AI model for this PR /switch claude-opus
/use Override the model for a single follow-up run /use claude-sonnet
/ultrafix Loop review→fix cycles until score goal is met /ultrafix or /ultrafix goal=8 max=10

🤖 Generated by ProPR
Processing comment ID: 7144008438✓

Applied F5. `persistToDatabase` now returns `detailsPersisted: false` when the execution row commits but a detail batch exhausts its retries. It returns `true` after all batches finish, including for empty or absent logs. A committed row keeps its claim in either case, and `recordLLMMetrics` still returns `Promise<void>`.

All 39 focused persistence and metrics tests passed, including four new SQLite regressions that assert the returned status directly. Core typechecking and lint passed. The separate live Redis suite was stopped because Redis was unavailable.

PR: integry#3782
Comment by: @integry (ID: 7144008438)
Model: GPT-6.2 Astra

ProPR-Agent: codex/gpt-6.2-astra
@integry

integry commented Nov 24, 2026

Copy link
Copy Markdown
Owner

/review

@propr-dev

propr-dev Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

✅ AI Code Review Complete requested by @integry

Posted 1 review:

View Task Details

@propr-dev

propr-dev Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

🔍 AI Code Review — codex:gpt-6-astra

Overall Evaluation

Ready to merge within scope. The change directly addresses oversized SQLite inserts with bounded batches, preserves execution summaries on detail failure, and stays proportionate to the objective.

✅ Bounded, idempotent writes — Batches contain at most 100 rows, preserve original sequence numbers, and use the existing unique constraint to skip previously stored details.

✅ Explicit failure reporting — Exhausted retries retain the execution row, return detailsPersisted: false, and log the execution ID and expected detail count.

✅ Relevant regression coverage — Added tests exercise real SQLite migrations, long conversations, transient failures, partial persistence, repeated inserts, and empty logs.

This assessment is based on static review of the supplied code. No commands were run, and no current-head check runs were reported.

Merge blockers

No merge blockers.

Suggestions

These are optional follow-ups and are not sent to /fix.

S14: 🟢 Assert repaired rows preserve content

In test/llmExecutionDetailPersistence.test.ts, the partial-repair test supplies different metadata for already persisted rows but checks only sequence numbers afterward. Also asserting that existing rows retain their original content would directly protect the conflict-ignore behavior against an accidental future switch to overwriting rows. This is optional because the current implementation explicitly uses .ignore().

Score

The implementation satisfies the scoped objective with focused changes and substantial regression coverage. Static review found no merge blockers; test execution remains unverified in this review.

Score: 9/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 21s
  • Tokens: 47,357 (46,947 in / 410 out)
  • Cost: $0.36

View Task


💡 Next step: Comment /fix to address every F# merge blocker, /fix all for every pending blocker and suggestion, or name records explicitly, as in /fix F3 S5.
F# and S# IDs increment across review comments and remain permanent, so selectors such as /fix F3 F5 stay unambiguous across cycles. S# suggestions stay optional: they are implemented only when you name them or request /fix all, and they never relax a merge blocker.

Copy and edit to choose records from this review:

/fix S14

🤖 Review by ProPR

@integry
integry marked this pull request as ready for review November 24, 2026 23:39
@integry integry added AI and removed AI labels Nov 29, 2026
@integry

integry commented Dec 1, 2026

Copy link
Copy Markdown
Owner

Verified before merge: merged onto current main and ran llmExecutionDetailPersistence plus the llmMetricsRecording, llmMetricsClaimRecovery and llmMetricsFailedExecutions suites against real SQLite (node:22): 38/38 pass, including the 5,000-event run. Core tsc is clean. Thanks @czehentner!

@integry
integry merged commit 254b6ee into integry:main Dec 1, 2026
45 checks passed
integry added a commit to czehentner/propr that referenced this pull request Dec 1, 2026
Brings czehentner's OpenCode cost reporting (integry#3780) and execution-detail
persistence (integry#3782) into the epic. Conflicts resolved by keeping both sides:
reported provider cost and detail persistence from main, compute usage and
the runtime abstraction from the epic. Main's OpenCode response builder now
types its result from runAgent and wraps it with attachComputeUsage.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants