feat: project-local job logs via relative jobsDir (auto git-exclude, migration-safe) - #1
Merged
Merged
Conversation
…config-change-safe log lookup) A relative jobsDir (any config layer or PI_BGRUN_DIR) now resolves against the session's project root, putting logs inside the workspace — reachable for project-sandboxed analysis tools (ctx_execute_file/ctx_index) and scoped per checkout. Absolute paths behave exactly as before (migration-safe). With no recognizable project root a relative path falls back to the global dir instead of scattering logs. Project-local dirs are auto-added to .git/info/exclude (local-only, linked-worktree aware) so logs never pollute git status. bgtail now prefers the session record's logPath, so jobs stay readable across mid-session config changes (e.g. switching to project-local after upgrade).
… spaces ensureGitExcluded now memoizes only on success: a failed attempt (unwritable exclude file, unparseable .git pointer) is retried on the next bgrun instead of being permanently skipped. The gitdir pointer regex accepts paths containing spaces (was \S+, which truncated at the first space).
lloydsk
added this pull request to stack #3
September 10, 2026 16:35
This was referenced Sep 10, 2026
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.
What
Opt-in project-local job logs: a relative
jobsDir(from any config layer, orPI_BGRUN_DIR) now resolves against the session's project root, so logs land inside the workspace instead of the shared global dir. Set"jobsDir": ".pi-bgrun/jobs"in the project's.pi/pi-bgrun.json→ logs at<project>/.pi-bgrun/jobs.Why
ctx_execute_file/ctx_index) are confined to the project root — logs in~/.pi-bgrun/jobswere unreachable by them, forcing agents into uncapped raw reads. Project-local logs restore the intended whole-log analysis path with only derived summaries entering context.How it works
resolveJobsDirPath(pure, unit-tested): absolute → used as-is; relative + project root →<root>/<jobsDir>; relative + no recognizable root (no.git/.piat cwd) → global fallback (never scatters logs across arbitrary cwds); unset → global default..git/info/exclude— local-only, the tracked.gitignoreis never touched, linked worktrees (gitdir:file pointers) are supported, writes retry on transient failure (memoized only on success), and gitdir paths with spaces are handled.bgtailresolves a job's log from the session record'slogPathfirst, so jobs stay readable across mid-session config changes (e.g. switching to project-local right after upgrading).Migration
jobsDirconfigs behave byte-for-byte like v0.4.0 — nothing moves, nothing breaks.cleanupDays-retained);bgclean allsweeps them once you've switched.Testing
tsc clean; 43/43 node:test — 7 new: resolver units (absolute/relative/no-root/unset), exclude idempotency, linked worktree, spaces-in-gitdir, retry-after-transient-failure, project-local end-to-end (log lands in project + exclude written), and record-preference
bgtailacross a config change.