Skip to content

fix(provenance): stop size limits silently dropping secret provenance - #6867

Merged
icecrasher321 merged 3 commits into
stagingfrom
provenance/remove-arbitrary-limits
Aug 19, 2026
Merged

fix(provenance): stop size limits silently dropping secret provenance#6867
icecrasher321 merged 3 commits into
stagingfrom
provenance/remove-arbitrary-limits

Conversation

@icecrasher321

Copy link
Copy Markdown
Collaborator

Summary

  • A bundle-selection cap counted cells rather than rows, so a 25-column table insert lost secret provenance for every row past 400 — the whole batch was stamped unknown, with nothing logged. The same number lived in three layers (sender, runtime type guard, route contract); all three are gone, and a cross-layer test pins the sender's output against the contract so they can't drift apart again.
  • Consolidated the scattered provenance limits into one definition. The same two numbers — an 8MB serialized envelope and 10,000 distinct secrets — had been copied into seven modules under fourteen names, and several copies had drifted into bounding inputs (rows, cells, files, chunks) rather than the envelope.
  • Removed every limit that could refuse a legal payload: a 20-file cap that threw outright when a Function block exported 21 files (now paged, so every file still gets marked), a 100-row knowledge response cap, a memory record cap, and the table row/column caps. What remains is two envelope bounds plus page sizes that bound a statement and can never refuse.
  • Reads that proceed on unrecorded provenance now write a workspace-visible audit entry (secret_provenance.unrecorded) alongside the log line, aggregated per read rather than per record.
  • Added write-side cause logging: every path that can stamp a row unknown now names why, through a single chokepoint.
  • Fixed a classifier disagreement where a demoted row was read as legacy by the read path and the fork classifier but as unknown by the derived-transformation SQL, which turned ordinary column operations into bulk producers of unknowns.
  • Script migration returns existing unknown rows to the untracked state — the state the read path already tolerates, and which passes even once a surface is closed.

Type of Change

  • Bug fix

Testing

Tested manually. bun run lint, check:audits, and check-block-registry pass; type-check clean across apps/sim, packages/audit, packages/testing, packages/db. 4,837 tests pass across the provenance, table, knowledge, memory, uploads, contracts, and audit suites. One unrelated failure (unreadable-document.test.ts, OCR error-message assertion) reproduces on staging without these changes.

Notes for review:

  • The enforcement feature flag is deliberately untouched — the intent is to merge and watch the new cause logging trend before changing posture.
  • The derived-transformation classification SQL has no test coverage; that change is verified by reading, not by test.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

A bundle-selection cap counted cells rather than rows, so a 25-column
table insert lost secret provenance for every row past 400 — the whole
batch was stamped unknown with nothing logged. The same number lived in
the sender, the runtime type guard, and the route contract.

Consolidate every provenance limit into one definition: an 8MB
serialized envelope and 10,000 distinct secrets. The pair had been
copied into seven modules under fourteen names, and several copies had
drifted into bounding inputs — rows, cells, files, chunks — rather than
the envelope.

Remove every limit that could refuse a legal payload, add write-side
cause logging and a workspace-visible audit entry when a read proceeds
on unrecorded provenance, and repair the existing unknown rows.
@vercel

vercel Bot commented Aug 19, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview Aug 19, 2026 10:42pm

Request Review

@cursor

cursor Bot commented Aug 19, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes durable secret provenance behavior, audit surfacing, and a data repair migration on table rows—security-sensitive paths with broad blast radius, though enforcement flags are intentionally unchanged.

Overview
Secret provenance no longer refuses or silently drops coverage based on row, cell, file, or selection counts. Limits are consolidated in provenance-limits.ts to envelope size and distinct secret entries only; wide table writes, large memory reads, knowledge responses, and Function file exports are handled via paging or incremental folding instead of caps that stamped everything unknown.

Batch provenance export adds exportCommittedProvenanceForInputPathGroups so private bundles and table cell selections vouch in one indexed pass rather than per-selection rescans; the 10k selection cap is removed from the sender, runtime guard, and API contract (with cross-layer tests).

Fail-open durable reads now emit one workspace audit entry (secret_provenance.unrecorded) per read (memory/table paths aggregate counts); per-record reporting in importDurableSecretProvenance can be suppressed when the caller reports once. Table writes log causes when rows are persisted unvouched.

Operational fixes: derived row transformation SQL treats demoted rows like the read path (untracked without requiring absent sidecar); workspace file unknown-marking is paged past 20 files; script migration 0005 relabels backlog unknown table row sidecars to untracked with lock ordering aligned to writers. Blog copy explains deliberate read visibility vs run-boundary withholding.

Reviewed by Cursor Bugbot for commit a8e6233. Configure here.

@greptile-apps

greptile-apps Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR removes input-count limits that could silently discard secret provenance, centralizes the remaining envelope limits, and adds audit visibility for reads with unrecorded provenance.

  • Adds grouped provenance export so wide table writes remain bounded without refusing legal payloads.
  • Pages memory, knowledge, upload, and table provenance work instead of rejecting large inputs.
  • Adds cause logging and workspace-visible audit records for fail-open durable reads.
  • Repairs legacy unknown table-row provenance while preserving concurrent exact writes and consistent lock ordering.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains; the status recheck preserves concurrently written exact sidecars, and parent-first ordered locking resolves the previously reported deadlock path.

Important Files Changed

Filename Overview
packages/db/script-migrations/0005_repair_unknown_table_row_provenance.ts The migration now locks parent rows before sidecars, rechecks unknown status before deletion, advances keyset pagination even when concurrent writers repair a page, and addresses both previously reported concurrency failures.
apps/sim/executor/utils/resolved-secret-trace-registry.ts Adds indexed grouped provenance export to remove the wide-write selection cap while preserving per-group narrowing and incompleteness behavior.
apps/sim/lib/execution/model-input-provenance.ts Removes the duplicated selection-count cap, uses centralized envelope limits, and records concrete causes when a bundle cannot be vouched for.
apps/sim/lib/table/rows/secret-provenance.ts Consolidates table provenance classification and paging behavior while adding aggregated reporting for unrecorded reads.
apps/sim/lib/execution/durable-secret-provenance-enforcement.ts Extends unrecorded-provenance reporting with workspace-visible audit entries without changing the enforcement feature flag.

Reviews (3): Last reviewed commit: "fix(provenance): take the repair's locks..." | Re-trigger Greptile

Comment thread packages/db/script-migrations/0005_repair_unknown_table_row_provenance.ts Outdated
Comment thread apps/sim/app/api/memory/secret-provenance.ts
The repair matched sidecars by the id its page captured, so a
provenance-aware write committing between the snapshot and the delete
had its fresh exact sidecar removed and its marker cleared behind it —
a secret-bearing row left reading as legacy. The delete now re-checks
status, which under READ COMMITTED re-evaluates against the writer's
committed row so it no longer matches.

Walk the candidate set by keyset over row_id. A page whose rows were
all repaired concurrently clears nothing, and terminating on "cleared
nothing" ended the walk with the rest of the backlog untouched.

Memory reported unrecorded provenance twice, and counted records even
when the surface was enforced — auditing a fail-open read that had
actually failed closed.
@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@greptile

@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread packages/db/script-migrations/0005_repair_unknown_table_row_provenance.ts Outdated

@cursor cursor 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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 06f5e76. Configure here.

The repair deleted the sidecar and only then updated its parent row,
while mutateTableRowsWithSecretProvenance locks user_table_rows up front
and upserts the sidecar inside the same transaction. Opposite orders, so
an overlapping write deadlocked and Postgres resolved it by aborting
either the deployment or somebody's table write.

Lock the parent first, in id order, matching lockTableRows. Holding that
lock is also what makes the status re-check decisive rather than racy:
the writer commits its sidecar and its marker under the same lock, so
once it is held the write is either wholly done or has not begun.
@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@greptile

@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor 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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit a8e6233. Configure here.

@icecrasher321
icecrasher321 merged commit fcea50d into staging Aug 19, 2026
30 checks passed
@waleedlatif1
waleedlatif1 deleted the provenance/remove-arbitrary-limits branch August 20, 2026 00:29
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