Skip to content

fix(mothership): admit stored content to Chat per item through one gate - #8941

Merged
icecrasher321 merged 13 commits into
stagingfrom
fix/file-content-egress-provenance
Oct 14, 2026
Merged

icecrasher321 merged 13 commits into
stagingfrom
fix/file-content-egress-provenance

Conversation

@waleedlatif1

@waleedlatif1 waleedlatif1 commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Classify stored content in its authorized application use case, with per-item admission shared by Chat's CLI, direct tools and workbench callbacks. Keep existing eight-character matching, named placeholders, and fail-open handling of genuinely absent provenance.
  • Preserve ordinary queries, truthful counts/cursors, dynamic compiler file references, and clean knowledge exports. Remove table-wide predicate scans and categorical tool bans; classify actual returned content instead.
  • Bind file/media/compiler reads to the bytes they use, stop code before execution when a requested mount is refused, and report omitted files in partial ZIP downloads, including refusals during generated-document compilation. Correlate original compiler broker errors by their existing call IDs; preserve ordinary user errors and successful fallbacks. Keep mutation completion and effects distinct from withheld results.
  • Redact complete text before line windows or knowledge chunking, preserving original file line positions; preserve originals and truthful search locations when a preview cannot be shown. Authorize legacy compiler inputs consistently and keep valid cached documents usable. Reuse canonical identities for owned file reads and preserve typed size-limit errors. Keep grep line numbers stable after masking.
  • Check the captured inputs of a published generated document before Chat activates or returns its public link. Share the existing artifact store with the file application owner; stream generator source and stop uploaded binaries at their header.
  • Admit opaque image/audio/video references from the revision actually read and remove the duplicate precheck. Use the shared core application barrel and declare benchmark target authorization as metadata-only. Check knowledge-original storage keys against their captured provenance and count only admitted files against ZIP totals.
  • Keep exports streaming, bound delivered evidence with existing provenance budgets, and avoid repeated or bulk loading of inline knowledge originals. Remove obsolete observers and duplicated policy code.

Type of Change

  • Bug fix

Testing

  • Full root bun run test: 553 script tests and all 20 workspace tasks; 37,614 application tests passed (7 existing skips).
  • 300 PostgreSQL/Redis/storage integration checks, 53 focused application tests in the latest round, and the earlier document-processing suite.
  • Thirty-five independent guard-removal checks reproduced the new regressions; restored sources passed. Existing integration coverage also verifies non-Chat compatibility and late-change refusals.
  • Production build passed, including benchmark route collection.
  • Repository type-check, test-type ratchet, lint, all 59 audits, standard generators, and staging-aware block registry. The 24 benchmark integration cases also pass under both schema-push and migration setup.

Checklist

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

@vercel

vercel Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Oct 14, 2026 2:08am UTC

Request Review

@cubic-dev-ai cubic-dev-ai Bot 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.

All reported issues were addressed across 197 files

Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.

Turn on auto-fix | Re-trigger cubic

Comment thread apps/sim/lib/mothership/chat/process-contents.ts
Comment thread apps/sim/lib/workflows/application/operations.ts
Comment thread apps/sim/lib/mothership/tools/handlers/function-execute.ts
Comment thread apps/sim/lib/mothership/agent-cli/file-read-transport.ts
Comment thread apps/sim/lib/workflows/application/admit-run-files.ts Outdated
Comment thread apps/sim/lib/workspace-files/application/search-workspace-file-content.ts Outdated
Comment thread apps/sim/lib/knowledge/application/tags.ts Outdated
Comment thread apps/sim/lib/table/application/rows.ts Outdated
@greptile-apps

greptile-apps Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Critical impact] The PR appears safe to merge; no new blocking issue remains in the reviewed changes.

Summary

The PR moves stored-content checks into shared application use cases. Chat’s CLI, direct tools, and workbench callbacks use the same per-item admission path.

  • Chat checks each stored item before it reaches a response.
  • Chat reads and mounts only files admitted for that item.
  • Chat previews redact stored values before showing them.
  • Generated documents and downloads check the content they actually deliver.

Diagram

sequenceDiagram
  participant Task as Document task
  participant Worker as Isolated worker
  participant Host as File broker
  participant Download as Bulk download
  Task->>Worker: Read referenced file
  Worker->>Host: Call with broker ID
  Host-->>Worker: Refusal with matching ID
  Worker->>Worker: Remember original error object
  Worker-->>Download: Return propagated error ID
  Download->>Download: Restore host refusal and omit document
Loading

Reviews (12) · Last reviewed commit: "fix(sandbox): preserve broker error iden..." · Reviewed by Greptile

Comment thread apps/sim/lib/core/application/content-delivery.ts Outdated
Comment thread apps/sim/lib/mothership/chat/application/inline-images.ts
Comment thread apps/sim/lib/mothership/tools/sandbox-resource-transport.ts
@waleedlatif1
waleedlatif1 force-pushed the fix/file-content-egress-provenance branch from 3bb1031 to c77ebc3 Compare October 12, 2026 21:20
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot 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.

All reported issues were addressed across 207 files

Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.

Note: This PR contains a large number of files. cubic selects up to 200 of the highest-priority eligible files for this review, so some files may not have been reviewed.

Turn on auto-fix | Re-trigger cubic

Comment thread apps/sim/lib/knowledge/application/chunks.ts Outdated
Comment thread apps/sim/lib/mothership/chat/process-contents.ts
Comment thread apps/sim/lib/knowledge/application/admit-knowledge-content.ts Outdated
Comment thread apps/sim/lib/mothership/tools/server/files/doc-compile.ts Outdated
Comment thread apps/sim/lib/core/application/content-delivery.ts Outdated
Comment thread apps/sim/lib/mothership/__integration__/content-delivery-compat.integration.ts Outdated
Comment thread apps/sim/lib/mothership/chat/process-contents.ts Outdated
Comment thread apps/sim/lib/mothership/chat/process-contents.ts Outdated
Comment thread .cursor/rules/sim-content-delivery.mdc Outdated
Comment thread apps/sim/lib/mothership/content-delivery/registry-gate.ts
Comment thread apps/sim/lib/workspace-files/application/share-workspace-file.ts Outdated
Comment thread apps/sim/lib/mothership/chat/application/read-sandbox-file.ts
Comment thread apps/sim/lib/knowledge/application/tags.ts
Comment thread apps/sim/lib/mothership/tool-executor/executor.ts
@waleedlatif1
waleedlatif1 force-pushed the fix/file-content-egress-provenance branch from c77ebc3 to 335f1d9 Compare October 12, 2026 22:12
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot 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.

All reported issues were addressed across 212 files

Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.

Note: This PR contains a large number of files. cubic selects up to 200 of the highest-priority eligible files for this review, so some files may not have been reviewed.

Turn on auto-fix | Re-trigger cubic

Comment thread apps/sim/lib/workflows/application/admit-run-files.ts Outdated
Comment thread apps/sim/lib/mothership/chat/application/inline-images.ts
Comment thread apps/sim/lib/table/rows/secret-provenance.ts Outdated
Comment thread apps/sim/lib/table/rows/secret-provenance.ts Outdated
Comment thread apps/sim/lib/mothership/chat/process-contents.ts Outdated
Comment thread apps/sim/lib/workspace-files/application/share-workspace-file.ts
Comment thread apps/sim/lib/table/application/rows.ts
@waleedlatif1
waleedlatif1 force-pushed the fix/file-content-egress-provenance branch from 335f1d9 to 612fb47 Compare October 12, 2026 23:02
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

Comment thread apps/sim/lib/knowledge/application/chunks.ts Outdated
Comment thread apps/sim/lib/table/import-provenance.ts
@icecrasher321

Copy link
Copy Markdown
Collaborator

@greptile

@icecrasher321

Copy link
Copy Markdown
Collaborator

@cubic review

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

@cubic review

@icecrasher321 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot 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.

No issues found across 245 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Note: This PR contains a large number of files. cubic selects up to 200 of the highest-priority eligible files for this review, so some files may not have been reviewed.
You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.

Turn on auto-fix | Re-trigger cubic

waleedlatif1 and others added 12 commits October 13, 2026 18:24
…before gating

Seeds one clean, secret-bearing, unknown and unrecorded item per content store and snapshots
every shared content route as an API-key caller sees it, before any Chat delivery gate changes.
Content from workspace files, run files, knowledge and table rows now reaches
Chat's model only after each item is classified and admitted by the gate of
the surface it leaves through: the registry gate (Chat tools, CLI, mounts) or
the session gate (run_code sandbox proxy). Unknown items are excluded per
item instead of withholding whole results; items with recorded secrets are
redacted where text, refused where opaque. Non-Chat callers are unchanged.

Every operation that admits Copilot declares contentDelivery, and a sourced
use case must account for what it returns, or Chat's transports refuse the
response. Closes the bulk-download, search, run-file, base64, knowledge,
share, export, table and tools-execute paths, and redacts grep lines before
clipping them.
Committed writes answer saved-not-shown instead of a retryable error, keep
their panel refresh, and account per operation. Chat streams pin inline
bytes off, taint needs a registry, compile admits before its cache, owned
files bind to their context, and count/truncation oracles are closed for
Chat in knowledge, files search and row search. Table selection cells are
projected before escaping and coerced import cells keep their taint.
…ent delivery

Chat may share or see links only to clean files whatever the surface, text
is redacted before a line window cuts it, accounting follows a decision,
cached compiles and knowledge metadata bind to the versions they show,
row-search matches classify at their matched revision, and table counts
follow admitted rows.
A table read whose rows, counts, cursor or affected count depend on cell
values is refused for Chat, before the predicate runs, when the table has an
unvouched row or a secret in a referenced column. Inline run-file bytes are
collected per storage key, and table-selection fallbacks are projected.
@icecrasher321
icecrasher321 force-pushed the fix/file-content-egress-provenance branch from 4753b99 to d5b9e48 Compare October 14, 2026 01:40
@icecrasher321

Copy link
Copy Markdown
Collaborator

@greptile

@icecrasher321

Copy link
Copy Markdown
Collaborator

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@icecrasher321 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot 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.

All reported issues were addressed across 245 files

Note: This PR contains a large number of files. cubic selects up to 200 of the highest-priority eligible files for this review, so some files may not have been reviewed.
You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.

Turn on auto-fix | Re-trigger cubic

Comment thread apps/sim/lib/execution/sandbox/run-task.ts Outdated
@icecrasher321

Copy link
Copy Markdown
Collaborator

@greptile

@icecrasher321

Copy link
Copy Markdown
Collaborator

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@icecrasher321 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot 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.

No issues found across 247 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Note: This PR contains a large number of files. cubic selects up to 200 of the highest-priority eligible files for this review, so some files may not have been reviewed.
You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.

Turn on auto-fix | Re-trigger cubic

@icecrasher321
icecrasher321 merged commit a0e5f46 into staging Oct 14, 2026
53 checks passed
@icecrasher321
icecrasher321 deleted the fix/file-content-egress-provenance branch October 14, 2026 02:19

This branch was previously deployed

1 inactive deployment
Preview — 0fed0792 Deployed Oct 14, 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.

2 participants