Skip to content

Avoid reloading analysis inputs after inference and measure storage waits - #216

Merged
devhims merged 2 commits into
mainfrom
fix/analysis-asset-rechecks
Oct 20, 2026
Merged

devhims merged 2 commits into
mainfrom
fix/analysis-asset-rechecks

Conversation

@devhims

@devhims devhims commented Oct 20, 2026 •

Copy link
Copy Markdown
Owner

Problem / Motivation

Frame, storyboard and transcript analysis reload their complete saved inputs after inference just to check for deletion. Users wait for another catalog lookup and R2 download, including potentially several megabytes of transcript text.

What changed

Analysis now loads each input once and captures the session's SQLite deletion generation before that read. After inference, it checks the generation and selected asset rows synchronously. Deletion followed by retrieval of the same version still rejects the old analysis. Any session generation change, including an unrelated deletion, rejects the in-flight result.

%%{init: {'themeVariables': {'actorBkg': '#e2e8f0', 'actorTextColor': '#0f172a', 'signalColor': '#64748b', 'signalTextColor': '#64748b', 'sequenceNumberColor': '#ffffff', 'noteBkgColor': '#f1f5f9', 'noteTextColor': '#0f172a'}}}%%
sequenceDiagram
    autonumber
    participant App as Analysis tool
    participant Store as D1 and R2
    participant Model as Analyst
    participant Session as Session SQLite
    App->>Store: Load saved inputs (retained)
    App->>Model: Analyze inputs (retained)
    Model-->>App: Findings
    alt Before
        App->>Store: Reload full inputs (removed)
    else After
        App->>Session: Check generation and asset rows (added)
    end
Loading

The initial verified read remains; the final payload reload is replaced with a local availability check.

The published OpenAPI schema includes the new diagnostic stage. Correlated logs time analysis input reads. Frame diagnostics distinguish the overall catalog write window from the publication wait remaining after extraction. Overlapping durations must not be added.

The final check covers session deletion, not shared catalog or object removal during inference. Shared sources currently have no deletion policy. The run-scoped cache remains a separate PR. Retrieval still waits for persistence.

Tests

  • Platform TypeScript build passed.
  • All 13 OpenAPI tests and documentation consistency checks passed.
  • 194 affected unit tests passed.
  • 131 local Workers integration tests passed.

Coverage includes cancellation, deletion during loading and inference, session clearing, same-version restoration, and deterministic write-overlap timing. Production latency measurement remains outstanding. No migration is required.

@vercel

vercel Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
video2ctx-web Ready Ready Preview Oct 20, 2026 5:34am UTC

devhims commented Oct 20, 2026

Copy link
Copy Markdown
Owner Author

Verdict: changes needed for 88c36c2.

P2 — Regenerate the published OpenAPI schema for the new diagnostic stage.
At platform/src/lib/extraction-diagnostics.ts:7, adding catalog_write_wait changes the runtime API schema, but docs/api-reference/openapi.json was not regenerated. The published contract is now stale, test/openapi.test.ts:32 fails, and docs:check fails. Regenerate and commit the generated documentation, then rerun these checks. The OpenAPI suite passes all 13 tests at base 44933d2, so this is introduced by this head.

Verification:

  • Full platform Node unit suite: 1,995 passed, 56 skipped, 1 failed (OpenAPI parity).
  • Focused affected tests: 108 passed, already included in the unit count above.
  • Session-evidence Workers integration: 45 passed with real SQLite/R2 behavior.
  • TypeScript: passed.
  • Ten additional independent probes passed for deletion/cancellation boundaries, failure-drain timing, error preservation and diagnostic privacy.
  • GitHub Verify run 39370801645 failed, including Documentation and Platform checks. Vercel passed.

The new analysis availability checks correctly reject deletion during loading/inference, including same-version restoration, and avoid the second payload read. No additional regression found in the storage timing or error paths.

Separate existing limitation: a deterministic runtime probe reproduced a same-version delete/restore race during the asynchronous packet hash after the final tool check, on both this head and its base (agent-runtime-do.ts:855-857). This is not introduced here and is not counted as this PR's regression, but the tool-level fence does not establish an atomic guarantee through persistence.

Limits: no production latency measurement or live provider calls; shared-catalog/object removal during inference remains outside the documented session-only check. No implementation changes, push, merge or deployment performed.

devhims commented Oct 20, 2026

Copy link
Copy Markdown
Owner Author

Verdict: approve 0b13463.

The previous P2 is resolved. This commit changes only docs/api-reference/openapi.json, adding catalog_write_wait at all four generated enum occurrences. It now matches the runtime schema; no source, test or dependency changes were introduced after the previous review.

Fresh verification at this head:

  • 1,996 repository Node unit tests passed, 56 skipped.
  • Four additional independent timing/error/privacy probes passed.
  • OpenAPI parity, documentation freshness check and TypeScript passed.
  • GitHub Verify run 39375589369 completed successfully; Vercel passed.

The 45 session-evidence Workers integration tests and six additional deletion/cancellation probes passed during the prior review of unchanged runtime code; those were not rerun for this documentation-only delta. No new blocking findings.

The separately documented preexisting delete/restore race after the final tool check remains unchanged, as do the session-only availability boundary and lack of production latency measurements. This approval covers the PR changes, not a claim that those existing limitations are fixed. No merge or deployment performed.

@devhims
devhims merged commit 10a56e1 into main Oct 20, 2026
11 checks passed
@devhims
devhims deleted the fix/analysis-asset-rechecks branch October 20, 2026 05:44

This branch was successfully deployed

1 active deployment
Preview — 0b134633 Deployed Oct 20, 2026 by vercel[bot]
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