fix(files): keep the pod's own S3 uploads out of the sync guard (CLEAN-115) - #111
Merged
Merged
Conversation
…N-115) The runtime's fs.watch pusher uploads every local change (usage.json on each LLM call, memory, sessions), so the CLEAN-50 guard listed those objects as "edited in S3" on every Sync. Ranch now tags each write it makes with object metadata origin=ranch; the guard keeps only tagged objects among the newer-than-baseline candidates (one HeadObject each). Admin: the header pill no longer claims "Agent copy is newer" — it says the agent is running, the tooltip explains the watcher, and the 409 dialog says the files were edited from Ranch. Spec 008 gets an R8 amendment on the watcher and the residual runtime-side risk. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
maksymhryzodub-prog
force-pushed
the
fix/CLEAN-115-sync-guard-origin
branch
from
September 24, 2026 12:02
c8147cc to
a3f8441
Compare
maksymhryzodub-prog
changed the base branch from
feat/CLEAN-112-advanced-file-management
to
main
September 24, 2026 12:02
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Jira: CLEAN-115
Rebased onto
mainafter #110 (CLEAN-112) merged. Root version bumped to 0.3.63.Problem
While an agent runs, the Files tab shows an amber "Agent copy is newer (HH:MM) — Sync now" pill at all times, and every Sync after the first LLM call opens "Overwrite newer files in S3?" listing
data/usage.json, a file nobody touched from Ranch.The runtime's fs.watch pusher (30 s debounce, always on with
S3_BUCKET) uploads every local change:usage.jsonon each LLM call, memory, sessions. The CLEAN-50 guard only comparesLastModifiedagainstmax(lastSyncAt, lastPullAt − 60 s), so the pod's own upload is indistinguishable from a console edit. Spec 008 R1 described the bridlesyncevent as the only push path and missed the watcher.Change
API
origin=ranch(RANCH_ORIGIN_METADATA). Template copies viaCopyObjectstay untagged on purpose: they land before the boot pull and are never newer than the baseline.IFileGateway.wasWrittenByRanch(agentId, path)— oneHeadObject, false when absent.SyncGuardService.assesskeeps only tagged objects among the newer-than-baseline candidates. Files at or below the baseline are not looked up. The agent toolsync_agent_filesshares the guard and benefits automatically.ApiResponseandSyncConflictDto.atRisktext say "edited from Ranch"; swagger + admin/app SDK regenerated (doc comments only).Admin
Docs
specs/008 research.mdR8: the watcher, the fix, and the residual risk only the runtime can close (a Ranch edit to a file the pod rewrites itself is overwritten by the next watcher flush; hardening = runtime tags its uploads and/or heads before overwriting).specs/017 quickstart.mdstep 6 updated.Twin console check
app/slices/agenthas nofilesub-slice and no reference tolastPullAt/copyPill, so nothing to mirror there.apponly received the regenerated SDK doc comments.Verification
jest src/slices/agent/file src/slices/bridle: 31 suites, 422 tests green, including the newfile.gateway.origin.spec.ts(metadata onsaveRaw,putObjectRaw,syncSkills;wasWrittenByRanchtrue / false / absent) and three newsyncGuard.service.spec.tscases.nest build,generate:swagger,admin/appbuild:api,nuxt typecheck(admin) — clean.data/usage.json; a file saved from the console while the agent runs must still trigger it. Note that objects written before this deploy carry no tag, so a pre-deploy console edit is treated as a pod upload until it is saved again.🤖 Generated with Claude Code