Repository navigation
🌱 test(crux/sandbox): cover Cline provider close/validation edges in PodmanLauncher - #16587
Conversation
…dmanLauncher Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Changelog: this PR changes code but carries no changelog entry If it is user-visible — a feature, a fix an operator would notice, a This is a reminder, not a gate; it never blocks a merge. |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of No conflicting open PRs or same-file overlaps were found. |
There was a problem hiding this comment.
Read the four tests against v5 (crux/sandbox/sandbox.go, cline_provider.go, crux/cline/provider_file.go). Each one reaches the branch it claims, and the trickiest one is sound:
TestRunReportsClineProviderCloseFailurechmods the staging root (provider-mounts, two levels above the mount file) to0500while leaving the per-runprovider-*dir at0700. That is the right split:MountFile(provider_file.go:95-107) only checks the stage dir and file perms, soPodmanArgsstill succeeds and the fixture "podman" runs; thenClose(provider_file.go:134-141) can truncate and unlinkproviders.jsonbutRemoveAllcannot rmdir the stage from a read-only parent, so it returnscannot remove private Cline provider stage, whichRun's first defer joins intorunErrafter redacting stdout (sandbox.go:58-64). The surviving-directory assertion follows from the same mechanism. Restoring0700in at.Cleanupregistered after the fixture's ownp.Close()cleanup means it runs first (LIFO), so the fixture's retry removes the stage andTempDircleanup is not left with an undeletable tree. Root skip is correct since root bypasses the directory write check.TestClineProviderArgsRejectsClosedCapabilityhitscline_provider.go:19viaMountFile's closed check (provider_file.go:92).- The
--thinkingloop appends to the canonical fixture command, which carries no--thinking, so the duplicate-flag guard is not tripped; the second half drops only--prompt-file, hitting the required-flag loop atcline_provider.go:78-82. TestRunDefaultsToPodmanBinaryFromPathpasses noClineProvider, so thePodmanBinaryfallback andLookPathfailure atsandbox.go:69-74are exercised without touching the Cline defers.
Test-only, no production change. Looks correct to me.
— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Read the four tests against cline_provider.go, sandbox.go and crux/cline/provider_file.go at 64a13d2. They exercise the branches they claim and the mechanics hold up:
- Closed capability —
PodmanArgsroutes toclineProviderArgs(sandbox.go:143), whoseMountFilecall hits thep.closedguard at provider_file.go:92; the fixture's deferred secondClose()is a no-op via thep.removedearly return (provider_file.go:131). - Required-flag miss — every flag in the crafted command passes the per-key switch (cline_provider.go:46-76); only the trailing required-set loop at :79 rejects it, so this really does cover that branch rather than an earlier one.
- Close failure after the run — chmod
0o500on the staging root is the right lever:MountFileonly inspectsp.dirandproviders.json(provider_file.go:99), so the mount still succeeds, andRemoveAllthen clears the file but fails on the finalrmdiragainst the read-only parent → provider_file.go:140-141, joined intorunErrby the deferred closure at sandbox.go:63-64. Redaction runs beforeClose()in that same defer, so the stdout assertion is sound. Cleanup order is correct too: the test's chmod restore is registered after the fixture'sClose()cleanup, so it runs first and the fixture can still remove the directory. - Default binary —
PodmanLauncher{}with noClineProviderreachesexec.LookPath("podman")(sandbox.go:70-74) with an emptyPATHdir.
The root skip is honest (RemoveAll cannot be made to fail as uid 0) and CI's test (rest …) and coverage jobs are green, so the tests run unskipped there. No production change, no new helpers, no sleeps. Looks correct to me.
— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Thank you for your contribution! Your PR has been merged. We'd love to hear how your experience was: share feedback |
Test Improvement
Adds
src/crux/sandbox/cline_provider_edges_test.go— four small in-package tests for thePodmanLauncherCline-provider path:clineProviderArgsrejects a capability whoseMountFilefails (closed provider)--thinkinglevel is accepted, and a command whose flags are all individually valid but which omits a required flag is still refusedPodmanLauncher{}falls back to thepodmanbinary name and reports it missing fromPATHProviderFile.Close()failure after the container ran is joined intoRun's error, with stdout still redacted (skipped as root, where the removal cannot be made to fail)Why.
crux/sandboxmeasures exactly 98.0% against its 98% floor on both the crux mirror (crux CI run 41818554790 @99542fc,coverage floorsjob) and hive's own gate — zero headroom. The five statements that remain are precisely these branches (hivecoverage-hourlyrun 41827832519 @4fc4ff1, artifactcoverage-profile-41827832519-1:cline_provider.go19/65/80,sandbox.go63/70). Any future one-line addition to the package without a test takes the floor red, which hive has already paid for once withcrux/lanes(#16411). Covering them now restores margin where it is cheapest. The last remaining uncovered line,worktree.go:110'sos.IsNotExistafterWalkDir, is unreachable because the walk callback already swallows that error, so it is deliberately left alone.Reuses the existing
clineLaunchFixture; no sleeps, no new helpers, no production change. Test-only, so no changelog fragment.Evidence: unit —
crux/sandbox98.0% with the listed statements at 0 hits; end-to-end — the Podman path is driven only by these in-package fixture launchers (no separate e2e suite reaches it), so this is a regression-risk finding on the gate margin rather than a behavioural hole.Built locally (
go buildof the package with test files renamed in a scratch package);go testis unavailable on this host, so CItest (rest …)reports the real figure.Filed by quality agent (ACMM L4/L6 — full mode)
— hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88