Skip to content

Require recorded source deletions in App Studio sync and commits - #1099

Merged
railgrid-prow[bot] merged 7 commits into
mainfrom
codex/app-studio-durable-source
Nov 15, 2026
Merged

railgrid-prow[bot] merged 7 commits into
mainfrom
codex/app-studio-durable-source

Conversation

@cwilhit

@cwilhit cwilhit commented Nov 14, 2026

Copy link
Copy Markdown
Collaborator

Change

Persist intentional file removals with their source revision in the Project working-copy ledger. File deletion, move, batch edits and restores record their removals. Recreating a path clears its earlier record. App Studio sync and both Git commit paths use those records when a source path is absent.

Add an explicit-deletion sync mode to the dev agent. Omission leaves existing files in place. The request uses a separate digest field so older dev agents reject it before touching files. Existing full-replacement sync callers retain their contract.

Rollout

Release Infrastructure first so its dev agents roll before the App Studio release. The Railgrid-dev workspace storage change is tracked in railgrid/ops#36 and uses a single App Studio replica with a persistent workspace claim.

Validation

Regenerated the Project schema and ran the App Studio API, workspace, project ledger and project reconciler suites plus the dev-agent suite. Regression cases cover an unexplained missing file, explicit deletion, and old agent rejection. Added deployment verification for a Git-free working copy and its sandbox.

@cwilhit

cwilhit commented Nov 14, 2026

Copy link
Copy Markdown
Collaborator Author

@mjudeikis-bot review

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

Two Warnings and one Note. I found no Critical issue.

Summary: the explicit-deletion design is sound. The old-agent rejection holds, because an older agent decodes the unknown explicitSourceDigest field, sees sourceRevision with no sourceDigest, and returns the 400 that postProjectComponentSync maps. The upgrade path and the pruning of records need attention.

Checked

  • Read beyond the diff: projectWorkspaceSyncFilesOnce and its caller, postProjectComponentSync, commitWorkspace, buildCommitBundle, uncommittedPaths, beginSourceMutation/completeSourceMutation/failSourceMutation, advanceAndRecord and planTreeReplacement, projectledger.Update/statusFrom/statusPatch, and the dev-agent handleSync decode and idempotency path.
  • Correctness: the upgrade-time gap is the first finding. The sync revision check and the rollback restore of previousDeletions look right.
  • Concurrency: the revision-exact SourceDeletions read turns a race into ErrSourceRevisionConflict, which the sync and commit paths already retry. No new shared state.
  • Tenancy and kcp: not applicable. All state is per-Scope in the project ledger and there are no new client or cross-workspace calls.
  • Provider contract: the dev-agent request changes in a compatible way, and old agents reject before touching files. manifest.yaml and the chart verbs are unchanged.
  • API and codegen: sourceDeletions is +optional, is a listType=map keyed on path, has bounds, and is regenerated in the CRD, kcp schema and chart copies. I did not run make verify-codegen.
  • Security: nothing parsed from a request is trusted, and no credential reaches a log or status.
  • Portal: not applicable, no portal changes.
  • Tests: reviewed the five added test files. The ledger recording and pruning are untested (Note), and the upgrade path is untested (Warning).
  • Commands (providers/app-studio): go build ./... and go vet ./... pass. go test -count=1 ./api/... ./workspace/... ./internal/projectledger/... ./controller/project/... passes.
  • Commands (providers/infrastructure/dev-agent): go test -count=1 ./... passes.
  • Commands (providers/infrastructure): go test ./... at the module root fails to set up because portal/dist is not built. That is an environment limit and unrelated to the diff.
  • Not run: make lint, make verify-codegen and make verify-provider-contract. The e2e suites were skipped because the PR changes no provider route or manifest, and the sandbox has no cluster.

if err != nil {
if errors.Is(err, os.ErrNotExist) {
if !deletions[path] {
return commitBundle{}, fmt.Errorf("workspace file %q is missing without a source deletion record", path)

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.

Warning: Deletions already pending at upgrade have no record, so the commit fails on every reconcile
SourceDeletions is only written by mutations that run on this build. A project that deleted a file before the upgrade has that path in status.workspace.uncommittedPaths and no sourceDeletions entry. buildCommitBundle then hits os.ErrNotExist and returns this error, and commitWorkspace returns dirty: true with that error. The whole commit, including unrelated dirty files, fails on each reconcile until the user re-creates the missing file. api/llm.go:948 fails the same way, and the sync path (development_sync.go) now silently never deletes the file. The PR body says nothing about existing projects.
Options: backfill a record for every uncommitted path that is missing on disk, or skip the unrecorded path and leave it dirty, as the over-bound files are, so the other files still commit. For example:

if !deletions[path] {
	bundle.skipped[path] = "missing without a source deletion record"
	continue
}


// pruneSourceDeletions drops removals already applied to the development
// sandbox and settled in Git. A failed sync or a pending commit keeps its intent.
func pruneSourceDeletions(record *LedgerRecord) {

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.

Warning: Unverified: deletion records are never pruned for a project that has no preview checkpoint
pruneSourceDeletions returns early when LastPreviewCheckpoint == nil. A project with no dev sandbox never records a checkpoint, so each deletion record stays after its commit settles. Only re-creating the same path clears a record. projectledger.Update rejects more than MaxUncommittedPaths (1024) records with ErrLedgerCapacity. After about 1024 distinct paths are deleted over the project's life, every source mutation, including later deletes and edits, fails. I traced the code but did not reproduce this with a test.
If there is no sandbox to sync, Git settlement should be enough to drop the record:

if record.LastPreviewCheckpoint == nil {
	// no sandbox has ever been synced: only Git settlement holds the record
	record.SourceDeletions = slices.DeleteFunc(record.SourceDeletions, func(d SourceDeletion) bool { return !dirty[d.Path] })
	return
}

Build dirty before the early return.


// recordSourceDeletions replaces deletion intent for the paths touched by a
// successful mutation. Recreating a path invalidates any earlier deletion.
func recordSourceDeletions(record *LedgerRecord, changed, deleted []string, revision uint64) {

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.

Note: The ledger recording has no test of its own
No test in workspace/ or internal/projectledger/ mentions SourceDeletions. Nothing covers the new recording in DeleteFile, MoveFile, ApplyManagedTransaction, RestoreSnapshot and ReplaceTree. Nothing covers re-creating a path clearing its record, pruneSourceDeletions, or failSourceMutation restoring previousDeletions. The added tests start from a hand-removed file (TestProjectWorkspaceSyncOmitsMissingPathWithoutDeletionRecord) and from fixtures, so a record that is not written would only show up as a missing sync or commit deletion in production. Add table tests per mutation, checking SourceDeletions(ctx, scope, rev) after each.

@cwilhit

cwilhit commented Nov 14, 2026

Copy link
Copy Markdown
Collaborator Author

@mjudeikis-bot ptal again

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

Re-review of 21b5b2d..2a28c52. One Warning (unverified) and no Critical. The earlier findings are resolved.

Earlier findings

  • Resolved: deletions pending at upgrade. buildCommitBundle now skips a missing path that has no record (commit.go:432), keeps it dirty and commits the other files. The empty-bundle outcome now stays dirty when something was skipped (commit.go:305). The chart README describes the new behaviour.
  • Resolved: pruning without a preview checkpoint. pruneSourceDeletions now treats a project with no development sandbox as sandbox-settled and drops a record once Git has settled the path. HasRepository and HasDevelopmentSandbox come from the Project spec in recordFromProject.
  • Resolved: ledger recording had no tests. TestSourceDeletionsFollowWorkspaceMutations, TestSourceDeletionSurvivesFailedRecreation, TestSourceDeletionSurvivesLostRecreationReservation and TestPruneSourceDeletionsWaitsForRequiredConsumers cover recording, restore and pruning.

New in these commits

  • DiscardUnverifiedReservation and ExplicitDeletionsVerified handling: see the inline Warning.
  • The dev-agent file/directory transition handling (prepareExplicitSyncPaths), the manifest idempotency change and the post-reload re-run read correctly. A replay with explicit deletes is re-applied instead of short-circuited, which is right. I found no defect.
  • pruneSourceDeletions with no repository also drops the path from UncommittedPaths and its attributions. I found no consumer that needs them without a repository.

Checked

  • Read beyond the diff: commitWorkspace, resolvePendingCommit, ensurePendingCommit/requestPendingCommit, buildCommitBundle, beginSourceMutation/completeSourceMutation/failSourceMutation, RecordPreviewCheckpoint, SourceDeletions, recordFromProject/statusFrom/statusPatch, projectWorkspaceSyncSnapshot deletion collection (api/development_sync.go), and dev-agent handleSync, deleteAuthoritativeWorkspaceCandidates, removeManagedWorkspaceFile, manifest write path.
  • Correctness: one finding (below). The discard path, the retained records during a reserved mutation and the restore of previousDeletions in failSourceMutation trace correctly.
  • Concurrency: the discard runs under mutationMu and inside a ledger compare-and-swap that rechecks the request ID and Name == "". No new shared state.
  • Tenancy and kcp: not applicable. State is per Scope, with no new client or cross-workspace calls.
  • Provider contract: no route, verb, manifest or chart template change. The dev-agent request stays compatible, and the separate explicitSourceDigest field still makes older agents reject it.
  • API and codegen: explicitDeletionsVerified is +optional and omitempty, so stored Projects decode with false, which routes legacy bundles to the discard path. make verify-codegen ran and left the tree clean.
  • Security: nothing new parsed from a request. No credential reaches a log or status.
  • Portal: not applicable.
  • Tests: TestCommitWorkspaceDiscardsUnverifiedReservedBundle covers the discard of an unnamed legacy reservation. Nothing covers an unnamed reservation whose RepositoryCommit already exists in Code.
  • Commands: providers/app-studio: go build ./..., go vet ./... and go test -count=1 ./api/... ./workspace/... ./internal/projectledger/... ./controller/project/... all pass. providers/infrastructure/dev-agent: go test -count=1 ./... passes. Root make verify-codegen passes with no diff.
  • Not run: make lint, make verify-provider-contract and the e2e suites. No manifest, chart template or provider route changed, and the sandbox has no cluster.

// An older bundle may contain inferred deletions. Rebuild from the
// current ledger and leave any already-created RepositoryCommit to settle.
if hasPending && pending.RequestID != "" && pending.Name == "" && !pending.ExplicitDeletionsVerified {
cleared, err := r.Workspace.DiscardUnverifiedReservation(ctx, scope, pending.RequestID)

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.

Warning: Unverified: discarding an unnamed legacy reservation can orphan a RepositoryCommit that already exists
requestPendingCommit creates the RepositoryCommit through codecommit.Client.Commit (keyed by RequestID) and only then calls BindPendingCommitName. If the old build created the commit and failed or crashed before binding, the ledger holds RequestID != "", Name == "", ExplicitDeletionsVerified == false, and Code already holds a commit built from the legacy bundle, which may contain inferred deletions. This branch clears the reservation, so nothing tracks that commit any more. It can still land, deleting files in Git that the new rules would have kept, and the comment above says it is left to settle without any follow-up. I traced the code but could not construct the interleaving without a Code provider.
One option is to look the commit up by RequestID first and fail or block it before discarding. If that is not possible, state the window in the PR body. For example:

if hasPending && pending.RequestID != "" && pending.Name == "" && !pending.ExplicitDeletionsVerified {
	// cancel or fail any RepositoryCommit already created for pending.RequestID before dropping the reservation
	...
}

@cwilhit

cwilhit commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator Author

/approve

@railgrid-prow

railgrid-prow Bot commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cwilhit

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@railgrid-prow
railgrid-prow Bot merged commit 50fe8fe into main Nov 15, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants