You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
build: review pass 4 — address HIGH + MED findings from PR #177
HIGH:
#1 PruneResult.FreedBytes now reflects bytes actually reclaimed
(sum over result.Removed after the loop), not the optimistic
plan total. Honors the build-prune.schema.json contract under
partial failure.
#2 Prune now holds the FR-015 per-key flock around each entry's
removal — same lock builder.Run() acquires — so a concurrent
`trond build` cannot interleave with our manifest+artifact
delete. New non-blocking TryAcquireCacheLock variant
(posix: LOCK_EX|LOCK_NB; windows: TryLock) so a background
prune never stalls an interactive build; locked entries are
skipped with an info-level stderr line.
MEDIUM:
#3 Sha256IfExists's *ssh.ExitError classification is verified
against the actual wrap shape Exec emits (fmt.Errorf with %w)
via 3 new sub-tests in internal/target/ssh_sha256_classify_test.go.
Documents the invariant: changing Exec's wrap verb breaks
this and the test catches it.
#4 resolveBuild omits JDKVersion from CacheKey when Builder=host
— the BuilderImageDigest (sha256 of `java -version`) already
captures the actual JVM, so including --jdk would fragment
the cache across two invocations that produce identical
artifacts.
#5 findLargestFatJAR matches `find -path '*/build/libs/*.jar'`
exactly (parent dir must be `build/libs/`), not just any
`/build/libs/` substring. Pins cross-builder cache reuse:
host and docker builders pick the same fat JAR even in
unusual layouts (`build/libs/sub/x.jar`, `libs-archive/`,
wrong-order segments).
#6 TestRunner interface widened to pass outDir through so test
fakes can populate image-snapshot files. Adapter updated;
two existing test callers (apply, cmd) updated to the new
5-arg signature.
#7 build_prune footgun guard: `--keep-last N --confirm` with
no scoping filter is now rejected at both CLI and MCP
layers. Operator must either add --all (explicit acknowledge
of the near-wipe) or narrow with --orphan/--older-than.
Dry-run is exempt — the plan output is the affordance for
"what would keep_last remove".
Tests added (all green):
- TestPrune_FreedBytesOnlyCountsActuallyRemoved
- TestPrune_FreedBytesOnDryRunMatchesPlan
- TestPrune_AcquiresCacheLock
- TestFindLargestFatJAR_NestedAndDecoyPaths
- TestResolveBuild_HostBuilder_JDKVersionDoesNotFragmentCacheKey
- TestBuildPrune_KeepLastFootgunGuard (cobra, 3 sub-cases,
properly isolated via paths.SetBaseDir so the test never
walks the dev's real ~/.trond cache)
- TestBuildPrune_KeepLastAloneConfirmRejected (MCP, 3 sub-cases)
- TestSha256_ExitErrorClassification (3 sub-cases)
0 commit comments