Skip to content

feat: add shared Project files - #8610

Draft
mzxchandra wants to merge 14 commits into
codex/file-ownership-foundationfrom
codex/project-files
Draft

mzxchandra wants to merge 14 commits into
codex/file-ownership-foundationfrom
codex/project-files

Conversation

@mzxchandra

@mzxchandra mzxchandra commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add shared Project files for architecture notes and reference documentation, with folders, uploads, history, copy, recursive downloads, extraction, public links, document compilation and collaborative Markdown editing.
  • Use the same authorized operations for sessions, v2/CLI and delegated Mothership callers. Writes require an organization admin, an admin in an active environment, or write access in every active environment. Workspace API keys do not gain Project authority.
  • Keep execution files workspace scoped and chats personal/organization scoped. Separate creator attribution, authorization and billing from the shared file-owner interface, backed by explicit owner FKs in feat: establish shared file ownership foundation #8609.
  • Carry ownership through realtime and retention; preserve current authorization during concurrent joins and writes. Workspace and Project folders share atomic child relocation, while file purges commit cleanup intents and billing together.
  • Preserve file-browser settings and owner-qualified Project file/folder tabs in chat. Handle supported extensionless names, inferred MIME types, image previews, Project document assets, and draft-source copying consistently. Refresh sharing and copy destinations after uncertain responses or realtime changes, and disclose truncated CSV previews without offering workspace-only actions.
  • Require copy revisions, bound retention queries and sandbox payload allocation, rate-limit CSV previews, authorize HEAD without compilation or download side effects, and allow the collaborative snapshot envelope through the proxy while retaining ordinary JSON limits.

Stacked on #8609, above #8590; #8580 has merged. Retire incompatible consumers before enabling the default-off Project files flag. Companion Mothership #594 uses the same owner protocol and needs no change for these fixes. This PR adds no further migration.

Type of Change

  • New feature

Testing

  • Root lint, all 26 workspace type-check tasks, all audits, generated artifacts, docs manifest, block registry and migration checks pass.
  • Full root tests pass: 373 script tests and all 19 workspace tasks, including 34,849 app tests with 20 existing skips.
  • Fresh migration, replay and schema generation pass without drift. All 115 targeted PostgreSQL checks pass across ownership, history, sharing, cleanup, billing, search and chat context; all 20 Project Socket.IO checks and both upload/cache UI regressions pass.
  • The running app and relay pass 80 HTTP acceptance checks across browsing, history, rendering, public/password sharing, embedded sources, copying and realtime. Fifteen distinct Chromium checks verify scoped chat-history cleanup, Project folder navigation, lost sharing responses, cross-client copy destinations, CSV truncation and cancelled file drags.
  • Independent negative controls demonstrate the authorization, realtime, retention, search, reference-scanning, inline-cache, artifact-HEAD, optional-revision, scoped-resource, folder-dispatch and CSV-warning regressions. The latest owner-search suite passes all 15 checks on fresh migrated PostgreSQL; removing the authority guard fails the unchanged lock-order assertion.

Earlier revisions passed native browser collaboration and navigation checks. This revision adds Chromium file-state verification alongside HTTP, PostgreSQL and Socket.IO testing. Drag, sharing and cross-client copy cases passed with the fixes; supplemental negative runs for those three were blocked by dev-cache runtime crashes. Live-model testing and remote Python/XLSX generation remain unverified locally. CI is manually dispatched for the updated branches; workflow triggers and timeouts are unchanged.

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 4, 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 6, 2026 9:59pm UTC

Request Review

@mzxchandra

Copy link
Copy Markdown
Contributor Author

@greptile

@mzxchandra

Copy link
Copy Markdown
Contributor Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@mzxchandra 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 485 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.

Re-trigger cubic

Comment thread apps/sim/lib/file-retention/workspace-versions.ts
Comment thread apps/sim/lib/api/contracts/v2/project-file-extraction.ts
Comment thread apps/sim/lib/api/contracts/v2/openapi/project-file-shares.ts Outdated
Comment thread apps/sim/lib/api/contracts/project-file-uploads.ts Outdated
Comment thread apps/sim/app/api/projects/[id]/files/[fileId]/csv-preview/route.ts Outdated
Comment thread apps/sim/lib/api/contracts/v2/openapi/files-audit.ts
Reuse entity-owned file operations across Project UI, session APIs, v2/CLI,
and delegated Mothership callers. Add Project discovery, sharing, history,
copy, collaborative editing, and current-access invalidation while preserving
workspace execution boundaries and independent creator/payer attribution.

Keep activation gated behind the file-ownership compatibility foundation.
Run real HTTP suites through disposable fixture orchestration in CI.
@greptile-apps

greptile-apps Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Critical risk] Adds new public API routes for project file operations.

The changes reviewed since the previous review appear safe to merge, with no outstanding findings identified.

Summary

The PR adds shared Project files across the application, APIs, CLI, realtime collaboration, and file browser. Since the previous review, it also adds an embedded Project folder view and refreshes drag, sharing, copy-destination, and CSV-preview behavior.

Reviews (5) · Last reviewed commit: "fix(files): refresh scoped file views an..."

Comment thread apps/sim/lib/projects/files/application/authorization.ts Outdated
Comment thread apps/sim/app/workspace/[workspaceId]/files/project-files.tsx
@mzxchandra
mzxchandra force-pushed the codex/project-files branch from 547eb7b to a9fd086 Compare October 6, 2026 00:44
@mzxchandra

Copy link
Copy Markdown
Contributor Author

@greptile

@mzxchandra

Copy link
Copy Markdown
Contributor Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@mzxchandra 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 485 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.

Re-trigger cubic

@mzxchandra

Copy link
Copy Markdown
Contributor Author

@greptile

@mzxchandra

Copy link
Copy Markdown
Contributor Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

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

@greptile-apps

greptile-apps Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Comments Outside Diff

These findings could not be posted inline.

  • P1 Project admins can be denied apps/sim/lib/projects/application/authorization.ts:95 ▶

    When a user belongs to multiple organizations, this query loads just one membership without filtering for the Project’s organization. If it selects a different organization’s row, the later check treats the user as a non-admin. An administrator can then be denied Project administration or shared-file access despite having the required role.

@mzxchandra

Copy link
Copy Markdown
Contributor Author

Regarding the outside-diff finding “Project admins can be denied”: the premise of simultaneous memberships in multiple organizations is excluded by the current database invariant. packages/db/schema.ts declares member_user_id_unique on member.userId, installed by migration 0136_pretty_jack_flag.sql. A real PostgreSQL attempt to construct the proposed multi-organization fixture is rejected by that unique constraint before authorization runs. The membership lookup also compares the returned organization to the canonical Project organization. No authorization change is appropriate while this single-organization invariant remains in force.

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

Turn on auto-fix | Re-trigger cubic

Comment thread apps/sim/app/api/projects/[id]/files/inline/route.ts Outdated
Comment thread apps/sim/lib/api/contracts/mothership-resources.ts
Comment thread apps/sim/app/api/projects/[id]/files/[fileId]/artifact/route.ts
Comment thread apps/sim/lib/api/contracts/v2/openapi/project-file-downloads.ts Outdated
Comment thread apps/realtime/src/handlers/file-doc-owner.ts
Comment thread apps/sim/lib/api/contracts/workspace-file-versions.ts Outdated
Comment thread apps/sim/lib/api/contracts/copilot.ts
@mzxchandra

Copy link
Copy Markdown
Contributor Author

@greptile

@mzxchandra

Copy link
Copy Markdown
Contributor Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@mzxchandra 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 495 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.

Turn on auto-fix | Re-trigger cubic

Comment thread apps/sim/hooks/queries/utils/file-share-query-adapters.ts
Comment thread apps/sim/app/workspace/[workspaceId]/home/home.tsx
Comment thread apps/sim/hooks/queries/file-extraction.ts Outdated
Comment thread apps/sim/hooks/queries/workspace-file-table.ts
Comment thread apps/sim/lib/api/contracts/mothership-file-copy.ts
Comment thread apps/sim/executor/utils/resolved-secret-trace-registry.ts
@mzxchandra

Copy link
Copy Markdown
Contributor Author

@greptile

@mzxchandra

Copy link
Copy Markdown
Contributor Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@mzxchandra 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 498 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

This branch was previously deployed

1 inactive deployment
Preview — 587b892d Deployed Oct 6, 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