Skip to content

feat(#3640): directory-level fetching for pre/post scripts - #5443

Closed
fullsend-ai-coder[bot] wants to merge 1 commit into
mainfrom
agent/3640-dir-fetch-scripts
Closed

feat(#3640): directory-level fetching for pre/post scripts#5443
fullsend-ai-coder[bot] wants to merge 1 commit into
mainfrom
agent/3640-dir-fetch-scripts

Conversation

@fullsend-ai-coder

Copy link
Copy Markdown
Contributor

Summary

Extend resolveBaseScripts in compose.go to use directory-level fetching (git sparse checkout) for pre/post scripts resolved from URL bases, ensuring companion files are co-located at the BASH_SOURCE-relative path. This is the systemic fix for the recurring companion-file breakage pattern (#2705, #3182, #3069/PR #3393).

Related Issue

Fixes #3640

Changes

  • Added fetchBaseScriptOrDir wrapper that attempts directory-level fetching via TreeFetcher when the URL is a raw.githubusercontent.com URL, with automatic fallback to single-file fetchBaseFile for non-GitHub URLs and backward compatibility
  • Added fetchBaseScriptDirTree that uses git sparse checkout (analogous to fetchBaseSkillDir for skills) to fetch the script's containing directory, cache it via CachePutDir, and make all files executable
  • Updated resolveBaseScripts to use fetchBaseScriptOrDir for all script fields (pre_script, post_script, validation_loop.script, and forge-level equivalents)
  • Directory caching keyed by "scriptdir:<dirURL>" ensures sibling scripts share a single tree fetch (e.g., pre-code.sh and post-code.sh in the same scripts/ directory)
  • Non-script fields (validation_loop.schema) continue to use single-file fetchBaseFile

Testing

  • 10 new unit tests covering: directory fetch, sibling cache hit, fallback to single-file, no-directory-component, offline cache hit, offline fallback, script-not-found error, token hint, integration with LoadWithBase
  • All existing tests pass (0 failures across full harness test suite)
  • go vet and go build pass
  • Secret scan passes

Checklist

  • PR title follows Conventional Commits (correct type, ! for breaking changes)
  • I wrote this contribution myself and can explain all changes in it

Closes #3640

Post-script verification

  • Branch is not main/master (agent/3640-dir-fetch-scripts)
  • Secret scan passed (gitleaks — 675086c5e606fe1ea9c09c22e1aa617aa17afeae..HEAD)
  • PR body secret scan passed (gitleaks — no-git)
  • Pre-commit hooks passed (authoritative run on runner)
  • Tests ran inside sandbox

Extend resolveBaseScripts in compose.go to fetch the containing
directory of pre/post scripts (via git sparse checkout) instead
of fetching each script as an isolated file. This ensures
companion files (helper scripts, Python tools, etc.) are
co-located at the BASH_SOURCE-relative path, preventing the
recurring companion-file breakage pattern seen in #2705, #3182,
and #3069.

When the URL is a raw.githubusercontent.com URL, the new
fetchBaseScriptOrDir function uses TreeFetcher to fetch the
full directory tree. When the URL cannot be parsed for
directory-level fetching, it falls back to the existing
single-file fetch via fetchBaseFile for backward compatibility.

Directory caching is keyed by "scriptdir:<dirURL>" so sibling
scripts in the same directory (e.g., pre-code.sh and
post-code.sh) share a single tree fetch -- the second script
hits the cache populated by the first.

Note: pre-commit hooks could not run in the sandbox due to
network restrictions (git fetch origin --tags returned 403).
The post-script runs an authoritative pre-commit check on the
runner.

Closes #3640
@fullsend-ai-coder
fullsend-ai-coder Bot requested a review from a team as a code owner July 22, 2026 07:30
@fullsend-ai-coder fullsend-ai-coder Bot added the ready-for-review Triggers review agent dispatch label Jul 22, 2026
@fullsend-ai-review

fullsend-ai-review Bot commented Jul 22, 2026

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 7:32 AM UTC · Completed 7:50 AM UTC
Commit: a9a3df2 · View workflow run →

@rh-hemartin

Copy link
Copy Markdown
Member

This was solved at another point, I requested coding by mistake. Closing.

@github-actions

Copy link
Copy Markdown

Site preview

Preview: https://aba9cb20-site.fullsend-ai.workers.dev

Commit: a9a3df26b9340aa1e4540466449c9b298fcf7143

@fullsend-ai-retro

fullsend-ai-retro Bot commented Jul 22, 2026

Copy link
Copy Markdown

🤖 Finished Retro · ✅ Success · Started 7:35 AM UTC · Completed 7:53 AM UTC
Commit: a9a3df2 · View workflow run →

@fullsend-ai-review

Copy link
Copy Markdown

Review skipped — this PR is already closed.

The /fs-review command only reviews open pull requests.

Posted by fullsend post-review check

@fullsend-ai-retro

Copy link
Copy Markdown

Retro: PR #5443 — Wasted code agent run on already-resolved issue

What happened: On 2026-07-22, a human (rh-hemartin) accidentally triggered /fs-code on issue #3640 ("directory-level fetching for pre/post scripts"). The issue had already been resolved 3 days earlier via script bundling in fullsend-ai/agents PR #38 (merged Jul 19), but issue #3640 was never updated to reflect this. The code agent ran for ~14.5 minutes, spent $4.99, produced 626 lines of working code across 2 files with 10 new tests, and opened PR #5443. The human closed the PR 2 minutes later saying "This was solved at another point, I requested coding by mistake." The review agent also started but the PR was closed before it completed.

Root causes: (1) The human had no way to cancel the in-flight code agent run after realizing the mistake. (2) Issue #3640 had no signal that it was already resolved — the fix landed in a different repo (fullsend-ai/agents) and was never reflected back on the source issue.

Existing issue evidence: This retro provides fresh evidence for several open issues tracking cross-repo visibility gaps:

Novel finding: No existing issue proposes a general-purpose human-initiated slash command to cancel an in-flight agent run. The closest mechanism is /fs-fix-stop (which only prevents future fix dispatches, doesn't cancel running runs). A /fs-cancel command would have directly prevented the $4.99 waste here — the human realized the mistake within minutes but had no recourse.

Proposals filed

@codecov

codecov Bot commented Jul 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 70.11494% with 26 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/harness/compose.go 70.11% 13 Missing and 13 partials ⚠️

📢 Thoughts on this report? Let us know!

@github-actions
github-actions Bot deleted the agent/3640-dir-fetch-scripts branch August 23, 2026 03:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-review Triggers review agent dispatch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Harness compose should support directory-level fetching for pre/post scripts to prevent recurring companion-file breakage

1 participant