Repository navigation
Require recorded source deletions in App Studio sync and commits - #1099
Conversation
|
@mjudeikis-bot review |
mjudeikis
left a comment
There was a problem hiding this comment.
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:
projectWorkspaceSyncFilesOnceand its caller,postProjectComponentSync,commitWorkspace,buildCommitBundle,uncommittedPaths,beginSourceMutation/completeSourceMutation/failSourceMutation,advanceAndRecordandplanTreeReplacement,projectledger.Update/statusFrom/statusPatch, and the dev-agenthandleSyncdecode and idempotency path. - Correctness: the upgrade-time gap is the first finding. The sync revision check and the rollback restore of
previousDeletionslook right. - Concurrency: the revision-exact
SourceDeletionsread turns a race intoErrSourceRevisionConflict, which the sync and commit paths already retry. No new shared state. - Tenancy and kcp: not applicable. All state is per-
Scopein 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.yamland the chart verbs are unchanged. - API and codegen:
sourceDeletionsis+optional, is alistType=mapkeyed onpath, has bounds, and is regenerated in the CRD, kcp schema and chart copies. I did not runmake 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 ./...andgo 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 becauseportal/distis not built. That is an environment limit and unrelated to the diff. - Not run:
make lint,make verify-codegenandmake 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) |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
|
@mjudeikis-bot ptal again |
mjudeikis
left a comment
There was a problem hiding this comment.
Re-review of 21b5b2d..2a28c52. One Warning (unverified) and no Critical. The earlier findings are resolved.
Earlier findings
- Resolved: deletions pending at upgrade.
buildCommitBundlenow skips a missing path that has no record (commit.go:432), keeps it dirty and commits the other files. The empty-bundle outcome now staysdirtywhen something was skipped (commit.go:305). The chart README describes the new behaviour. - Resolved: pruning without a preview checkpoint.
pruneSourceDeletionsnow treats a project with no development sandbox as sandbox-settled and drops a record once Git has settled the path.HasRepositoryandHasDevelopmentSandboxcome from the Project spec inrecordFromProject. - Resolved: ledger recording had no tests.
TestSourceDeletionsFollowWorkspaceMutations,TestSourceDeletionSurvivesFailedRecreation,TestSourceDeletionSurvivesLostRecreationReservationandTestPruneSourceDeletionsWaitsForRequiredConsumerscover recording, restore and pruning.
New in these commits
DiscardUnverifiedReservationandExplicitDeletionsVerifiedhandling: 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. pruneSourceDeletionswith no repository also drops the path fromUncommittedPathsand 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,projectWorkspaceSyncSnapshotdeletion collection (api/development_sync.go), and dev-agenthandleSync,deleteAuthoritativeWorkspaceCandidates,removeManagedWorkspaceFile, manifest write path. - Correctness: one finding (below). The discard path, the retained records during a reserved mutation and the restore of
previousDeletionsinfailSourceMutationtrace correctly. - Concurrency: the discard runs under
mutationMuand inside a ledger compare-and-swap that rechecks the request ID andName == "". 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
explicitSourceDigestfield still makes older agents reject it. - API and codegen:
explicitDeletionsVerifiedis+optionalandomitempty, so stored Projects decode with false, which routes legacy bundles to the discard path.make verify-codegenran and left the tree clean. - Security: nothing new parsed from a request. No credential reaches a log or status.
- Portal: not applicable.
- Tests:
TestCommitWorkspaceDiscardsUnverifiedReservedBundlecovers 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 ./...andgo test -count=1 ./api/... ./workspace/... ./internal/projectledger/... ./controller/project/...all pass.providers/infrastructure/dev-agent:go test -count=1 ./...passes. Rootmake verify-codegenpasses with no diff. - Not run:
make lint,make verify-provider-contractand 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) |
There was a problem hiding this comment.
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
...
}|
/approve |
|
[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 DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
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.