Skip to content

fix: clean up scan history indexing - #1150

Merged
mldangelo-oai merged 2 commits into
mdangelo/codex/pr939-split-26-document-reader-buildfrom
mdangelo/codex/pr939-split-27-sessions
Oct 4, 2026
Merged

mldangelo-oai merged 2 commits into
mdangelo/codex/pr939-split-26-document-reader-buildfrom
mdangelo/codex/pr939-split-27-sessions

Conversation

@mldangelo-oai

@mldangelo-oai mldangelo-oai commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

Part 27 of 46. Previous: #1149 · Next: #1151 · Stack index

Summary

Store the session IDs associated with each scan in SQLite so history and cost accounting retain follow-up and earlier execution sessions. Migrate saved thread associations and repair composition membership in existing databases.

Changes

  • Store execution session IDs in SQLite and use them for Standard and Deep Scan accounting; attach follow-up sessions without replacing the original continuation.
  • Add migration 45 for session history and migration 47 to remove an unused severity index. Keep the unindexed-assessment repair already introduced as migration 46 in part 2.
  • Add migration 48 to repair composition membership in databases that already applied earlier migrations.
  • Use the finding occurrence’s scan when filtering comparison history, and cover upgrades with existing child rows.

Testing

Local checks for the implementation:

  • Local membership migration tests passed for databases that had already applied the earlier migrations.

Checks against the complete stack passed: SDK and MCP typechecks, formatting, Ruff, the SDK build, portable plugin compatibility and its tests, focused recovery/accounting tests, and local-artifact package smoke using exact cached dependencies. The package check was not a clean registry install. See this PR’s Checks tab for CI results for its current commit.

Risk and rollout

Database readers and writers change together. New migration IDs apply without rerunning earlier migrations. Migration 46, introduced in part 2, remains recorded once; migration 48 repairs composition membership in existing databases.

Public disclosure review

  • No customer, partner, prospect, or user identities, data, or identifying details are included.
  • No credentials, personal data, private source, scan findings, or nonpublic links or tickets are included.
  • I reviewed the branch name, title, description, commits, changes, comments, logs, screenshots, attachments, and links for public disclosure.

@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-04T17:35:46.334648Z f824b38 Draft marked ready
🔒 Security Review ⚠️ Failed 2026-10-04T17:35:52.619910Z f824b38 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Existing version-44 databases skip the composition-child backfill, causing legacy child scans to be misclassified.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Persists scan-session associations in SQLite and migrates legacy scan metadata for durable history and accounting.

Changes:

  • Adds migrations for execution sessions, severity recovery, and composition membership.
  • Updates usage, history, and composition readers to use SQLite.
  • Expands migration, accounting, and query-performance tests.
File Description
sdk/​typescript/​tests-ts/​classify-scan-severity.test.ts Tests legacy severity recovery.
plugins/​codex-security/​tests/​test_workbench_setup_and_migrations.py Expands migration coverage.
plugins/​codex-security/​tests/​test_workbench_scan_usage.py Tests migrated session accounting.
plugins/​codex-security/​tests/​test_workbench_scan_composition.py Tests composition membership migration.
plugins/​codex-security/​tests/​test_workbench_native_index_queries.py Guards history-query performance.
plugins/​codex-security/​tests/​test_workbench_db.py Updates expected schema.
plugins/​codex-security/​scripts/​workbench_severity.py Enables local module resolution.
plugins/​codex-security/​scripts/​workbench_schema.py Adds and applies migrations.
plugins/​codex-security/​scripts/​workbench_scan_usage.py Includes persisted execution sessions.
plugins/​codex-security/​scripts/​workbench_scan_history.py Narrows finding-history traversal.
plugins/​codex-security/​scripts/​workbench_db.py Persists attached scan threads.
plugins/​codex-security/​scripts/​workbench_composition.py Reads execution sessions from SQLite.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +1165 to +1168
elif version == 43:
backfill_composition_children(connection)
elif version == 45:
backfill_execution_threads(connection)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 41ff568470

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +1165 to +1166
elif version == 43:
backfill_composition_children(connection)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Run the membership backfill for databases already at v43

When upgrading a database created by the preceding release, migration 43 is already recorded, so the earlier if version in applied branch continues before this callback can run. Consequently, legacy Deep Scan children whose parent_scan_role remained NULL are never repaired and stay invisible to composition_children, omitting their findings and usage from historical parent scans. Put this recovery in a newly appended migration version, or otherwise execute it once for databases where v43 was previously applied.

Useful? React with 👍 / 👎.

@mldangelo-oai mldangelo-oai changed the title refactor: save scan sessions in SQLite refactor: store scan sessions in SQLite Oct 1, 2026

@faizan-oai faizan-oai 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.

Reviewed the SQLite session storage and migration changes at 592495a, including the documented compatibility boundary for earlier development databases. Session/runtime and migration coverage passes on the integrated stack; this head has successful CI. No new issue found in this increment.

@alandelong-oai alandelong-oai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed the SQLite session and migration changes at 592495a2fcbb90fcb9f81f34dc4900b605e79203 with three independent passes and root verification. One serious outstanding issue prevents approval: the membership backfill is attached to migration 43, so existing v43/v44 databases skip it. I reproduced an intact v44 upgrade to v47 leaving a legacy Deep Scan child with parent_scan_role = NULL; running the repair explicitly restores deep_pass. The existing migration comment covers the required fix.

Validation: 133 focused Python tests and 15 SDK severity tests pass. Additional probes verified migration 46 recovers matching unindexed severity rows. A suspected digest mismatch remains rejected by the public classification read API before and after migration, so I did not retain it as a separate finding.

@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-split-26-document-reader-build branch from e32fbde to a1fb609 Compare October 1, 2026 23:44
@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-split-27-sessions branch from 592495a to 55817ec Compare October 1, 2026 23:44

@alandelong-oai alandelong-oai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Three independent re-review passes and root reconciliation are complete for this restacked head.

The actual migration probe repairs stored Deep child membership automatically, before any explicit repair call.

Approval is for this change. Integrated-tip validation passed 1,357 SDK tests (31 skipped), 105 MCP tests (2 skipped), portable checks, types/builds and installed-package smoke. Other stack findings and known CI fixture failures still prevent the stack from being mergeable.

@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-split-27-sessions branch from 55817ec to 280c705 Compare October 2, 2026 00:36
@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-split-26-document-reader-build branch from a1fb609 to 20da3e0 Compare October 2, 2026 00:36

@alandelong-oai alandelong-oai left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Re-reviewed the real PR diff at 280c7056adef0d5b9c1e3e19a2e12dcc60a6c501. The patch is unchanged from the prior three-pass review. I reconciled the inherited changes in touched files and retained the prior verified findings and tests.

No serious outstanding finding identified in this patch; prior conclusions remain consistent with the unchanged change or the current re-review.

Validation across touched paths at branch tip 06e75cfe: 1,356 SDK tests, 867 Python tests plus 100 subtests, and 108 MCP tests passed; builds, types, portable checks and installed-package checks passed. These are integration checks at the branch tip, not a claim that every intermediate PR or its CI is clean. Latest workflow runs for this unchanged head were verified successful at 2026-10-02 01:26 UTC. Earlier failed or canceled job records are superseded; this CI status correction does not alter the review decision.

@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-split-27-sessions branch from 280c705 to 766fdfc Compare October 2, 2026 01:37
@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-split-26-document-reader-build branch from 20da3e0 to 55662ed Compare October 2, 2026 01:37
@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-split-27-sessions branch from 766fdfc to d712fa5 Compare October 2, 2026 01:56
@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-split-26-document-reader-build branch from 55662ed to 7c33edf Compare October 2, 2026 01:56

@alandelong-oai alandelong-oai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Retained the three independent passes for the identical patch and reconciled inherited touched-file changes at d712fa59d4e3.

No actionable introduced finding survives the independent reviews and root reconciliation of this exact patch, touched-file changes, and current integration checks.

Current tip 355ec321 passed 75 report-projection tests, portable source checks, SDK build:ci and plugin build. The immediately preceding tip fec36f1d passed 1,360 SDK tests, 873 Python tests plus 100 subtests, 109 MCP tests, builds/types and the clean 600-entry installed-package check. Only report_projection.py and its test changed between those tips; SDK/MCP runtime files are byte-identical. Both descend from main 008a8b4d. These are integration checks, separate from own-head probes. No native Windows local run.

No serious outstanding finding introduced by this PR. Code review approval does not establish CI or merge readiness.

@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-split-27-sessions branch from d712fa5 to daea94c Compare October 2, 2026 02:47
@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-split-26-document-reader-build branch from 7c33edf to 8d37974 Compare October 2, 2026 02:47

@alandelong-oai alandelong-oai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Retained the three independent passes for the verified identical patch and reconciled inherited touched-file changes at daea94c7cede.

No actionable introduced finding survives the independent reviews and root reconciliation of this exact patch and inherited changes in touched files.

Integrated tip 6ef8cbb8, based on 008a8b4d, passed 1,388 SDK tests, 879 Python tests plus 100 subtests, 109 MCP tests, portable checks, builds and the clean 600-entry installed-package check. These are branch-tip integration checks, separate from own-head probes; no local Windows execution was performed.

No serious outstanding finding introduced by this PR. Code approval is separate from CI and merge readiness.

@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-split-27-sessions branch from daea94c to 7cfc5e1 Compare October 2, 2026 03:52
@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-split-26-document-reader-build branch from 8d37974 to 5cf010f Compare October 2, 2026 03:52

@alandelong-oai alandelong-oai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Retained three prior independent passes for the verified identical patch and reconciled inherited touched-file changes at 7cfc5e1c3a36.

No actionable introduced finding survives the independent reviews and root reconciliation of this exact patch and inherited changes in touched files.

Branch tip 3e0083d9, based on 008a8b4d, passed 1,392 SDK tests, 881 Python tests plus 100 subtests, 109 MCP tests, builds, portable source checks and the 600-entry installed-package check. These are tip checks, separate from own-head probes. No local Windows run was performed. The tip excludes the dependency update merged separately in #1184; combined validation remains outstanding.

No serious outstanding finding introduced by this PR. Code approval is separate from CI and merge readiness.

@mldangelo-oai mldangelo-oai changed the title refactor: store scan sessions in SQLite fix: clean up scan history indexing Oct 4, 2026
Consolidate approved Deep Scan changes into the parent topic branch.
@mldangelo-oai
mldangelo-oai marked this pull request as ready for review October 4, 2026 17:35
@mldangelo-oai
mldangelo-oai merged commit 703c09e into mdangelo/codex/pr939-split-26-document-reader-build Oct 4, 2026
1 check passed
@mldangelo-oai
mldangelo-oai deleted the mdangelo/codex/pr939-split-27-sessions branch October 4, 2026 17:35
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.

5 participants