Repository navigation
feat: establish shared file ownership foundation - #8609
mzxchandra wants to merge 183 commits into
Conversation
…ty-enforcement # Conflicts: # apps/sim/lib/projects/__integration__/foundation.integration.ts
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…ty-enforcement # Conflicts: # apps/sim/lib/projects/__integration__/foundation.integration.ts
|
@greptileai review — d43cdd4 corrects the branch boundary: foundation owned-file creation uses its existing billing API; the newer accounting helper remains in #8610. |
|
@cubic-dev-ai review — d43cdd4 corrects the branch boundary: foundation owned-file creation uses its existing billing API; the newer accounting helper remains in #8610. |
@mzxchandra I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
No issues found across 220 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
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.
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
Preserve the upstream storage lock order and migration 0413; renumber pending file migrations to 0414-0420 without changing SQL. Correct aggregate file-delivery types and stale test fixtures, remove tests for the retired rollout gate, and retain the landed lifecycle requirement that ownership successors already have access.
|
@cubic-dev-ai review this PR |
@mzxchandra I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
1 issue found across 222 files
Confidence score: 3/5
- In
resource-handoff.ts, Project creator references can block membership removal or account deletion in an ownerless organization, even when the Project has a valid successor. Adjust the unions so those handoffs remain possible.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/sim/lib/billing/organizations/resource-handoff.ts">
<violation number="1" location="apps/sim/lib/billing/organizations/resource-handoff.ts:22">
P2: These unions make Project creator references require an organization owner, so membership removal or account deletion is blocked in an ownerless organization even when the Project has a valid successor. Keep these references on the Project-scoped succession path instead of applying the organization-owner gate.</violation>
</file>
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
|
@cubic-dev-ai review this PR |
@mzxchandra I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
3 issues found across 233 files
Confidence score: 3/5
- In
fetch-servable-workspace-file-buffer.ts, a generated document can render successfully but then fail to read or download when its owned-file contributor has a non-workspacecontext. Ensure this check handles that contributor context. - In
compiled-store.ts, rollback cleanup can delete a content-addressed cache object used by another successful render. Make sure rollback does not remove a shared object. - In
search-workspace-file-content.ts, ordinary UI and API-key searches can return a conflict if a file changes or is deleted between the index read and snapshot validation. Restrict this validation so routine searches can return their point-in-time results.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/sim/lib/workspace-files/application/search-workspace-file-content.ts">
<violation number="1" location="apps/sim/lib/workspace-files/application/search-workspace-file-content.ts:89">
P2: Ordinary UI and API-key searches now run this snapshot-validation transaction too, so an edit or deletion between the index read and this check turns a valid point-in-time result into a conflict. Restrict snapshot revalidation to classified Chat searches while retaining any owned-input access checks required for other callers.</violation>
</file>
<file name="apps/sim/lib/uploads/documents/compiled-store.ts">
<violation number="1" location="apps/sim/lib/uploads/documents/compiled-store.ts:178">
P2: Rollback cleanup can delete another successful render’s shared cache object: this callback records the content-addressed key before upload, and the Project caller later deletes recorded keys after a failed commit. Make cleanup conditional on a write-specific ownership/version, or track only keys proven newly created.</violation>
</file>
<file name="apps/sim/lib/workspace-files/application/fetch-servable-workspace-file-buffer.ts">
<violation number="1" location="apps/sim/lib/workspace-files/application/fetch-servable-workspace-file-buffer.ts:52">
P2: A generated document can successfully render with an owned-file contributor, but this check throws because its context is not `workspace`, failing the read or download after rendering succeeds. Skip the search-artifact receipt for unsupported dependency contexts instead of failing the render.</violation>
</file>
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
| context.workspaceId, | ||
| found.sources.map((source) => source.identity), | ||
| 'excerpt' | ||
| const provenance = await db.transaction(async (tx) => { |
There was a problem hiding this comment.
P2: Ordinary UI and API-key searches now run this snapshot-validation transaction too, so an edit or deletion between the index read and this check turns a valid point-in-time result into a conflict. Restrict snapshot revalidation to classified Chat searches while retaining any owned-input access checks required for other callers.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At apps/sim/lib/workspace-files/application/search-workspace-file-content.ts, line 89:
<comment>Ordinary UI and API-key searches now run this snapshot-validation transaction too, so an edit or deletion between the index read and this check turns a valid point-in-time result into a conflict. Restrict snapshot revalidation to classified Chat searches while retaining any owned-input access checks required for other callers.</comment>
<file context>
@@ -63,34 +77,68 @@ export const searchWorkspaceFileContent = defineAuthorizedWorkspaceFileUseCase({
- context.workspaceId,
- found.sources.map((source) => source.identity),
- 'excerpt'
+ const provenance = await db.transaction(async (tx) => {
+ await lockWorkspaceProject(tx, context.workspaceId)
+ const [current] = await tx
</file context>
| if (existing?.referencedInputIdentity === referencedInputIdentity) return | ||
| const pointer: PublishedArtifactPointer = { version: 1, referencedInputIdentity } | ||
| try { | ||
| onArtifactWrite?.(key) |
There was a problem hiding this comment.
P2: Rollback cleanup can delete another successful render’s shared cache object: this callback records the content-addressed key before upload, and the Project caller later deletes recorded keys after a failed commit. Make cleanup conditional on a write-specific ownership/version, or track only keys proven newly created.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At apps/sim/lib/uploads/documents/compiled-store.ts, line 178:
<comment>Rollback cleanup can delete another successful render’s shared cache object: this callback records the content-addressed key before upload, and the Project caller later deletes recorded keys after a failed commit. Make cleanup conditional on a write-specific ownership/version, or track only keys proven newly created.</comment>
<file context>
@@ -152,24 +161,26 @@ export async function loadCompiledDoc(
if (existing?.referencedInputIdentity === referencedInputIdentity) return
const pointer: PublishedArtifactPointer = { version: 1, referencedInputIdentity }
try {
+ onArtifactWrite?.(key)
await uploadFile({
file: Buffer.from(JSON.stringify(pointer), 'utf-8'),
</file context>
| contentUpdatedAt: fileRecord.contentUpdatedAt ?? fileRecord.updatedAt, | ||
| }, | ||
| dependencies: (result.contributingFiles ?? []).map((file) => { | ||
| if (!file.contentUpdatedAt || file.context !== 'workspace') |
There was a problem hiding this comment.
P2: A generated document can successfully render with an owned-file contributor, but this check throws because its context is not workspace, failing the read or download after rendering succeeds. Skip the search-artifact receipt for unsupported dependency contexts instead of failing the render.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At apps/sim/lib/workspace-files/application/fetch-servable-workspace-file-buffer.ts, line 52:
<comment>A generated document can successfully render with an owned-file contributor, but this check throws because its context is not `workspace`, failing the read or download after rendering succeeds. Skip the search-artifact receipt for unsupported dependency contexts instead of failing the render.</comment>
<file context>
@@ -36,4 +38,28 @@ export async function fetchAuthorizedServableWorkspaceFileBuffer(
+ contentUpdatedAt: fileRecord.contentUpdatedAt ?? fileRecord.updatedAt,
+ },
+ dependencies: (result.contributingFiles ?? []).map((file) => {
+ if (!file.contentUpdatedAt || file.context !== 'workspace')
+ throw new Error('Artifact input has no canonical workspace revision')
+ return {
</file context>
Summary
This PR targets
stagingand includes the landed #8590 and #8762 prerequisites. Project backend/API/CLI work follows in #8610; browser and Mothership integration follows in #8781. Those dependent changes are outside this PR.Rollout and rollback
Type of Change
Testing
Checklist