Skip to content

chore: housekeeping sweep — truth-path dedup, per-repo default branch, executor hardening, drop vestigial uv.lock#47

Merged
saagpatel merged 5 commits into
mainfrom
chore/housekeeping-sweep
Jun 6, 2026
Merged

chore: housekeeping sweep — truth-path dedup, per-repo default branch, executor hardening, drop vestigial uv.lock#47
saagpatel merged 5 commits into
mainfrom
chore/housekeeping-sweep

Conversation

@saagpatel
Copy link
Copy Markdown
Owner

Four independent housekeeping items, each its own commit. All reviewed via /code-review (one real bug caught + fixed — see commit d1d7c0e).

1. refactor(truth) — single-source the truth-latest filename

portfolio-truth-latest.json was reconstructed as a path-join in ~19 sites across 8 files. Introduced TRUTH_LATEST_FILENAME + truth_latest_path(output_dir) in portfolio_truth_types (the domain leaf) and routed every path-join + the one glob() through it. Human-readable error/log copy stays as prose. No behavior change.

2. feat(automation) — per-repo default branch for context-PR base

The bounded-automation executor opened context-PRs against a hardcoded main. Now detects each repo's actual default branch from the local origin/HEAD ref (no network), threads it through IdentityFields.default_branch, and resolves the PR base as explicit override > repo-detected > portfolio fallback. Additive optional field; "" means auto-detect.

3. fix(automation) — harden executor failure paths

  • Orphan branch: a failed apply_change after git checkout -b left the created branch behind, blocking retries. Now force-checkout the default branch (worktree is verified clean before apply_change, so -f only discards partial writes) + delete the orphan. The force-checkout is the review follow-up (d1d7c0e) — a plain checkout was blocked by the dirty tree from a partial apply_change, stranding the repo on the orphan.
  • Missing PR URL: when gh pr create succeeds (rc 0) with empty stdout, the PR exists (re-running would duplicate it), so the outcome stays applied but the missing reference is surfaced in the detail instead of silently recorded.

4. chore(deps) — remove vestigial uv.lock

Nothing reads it: every install path (ci.yml, audit.yml, release.yml) uses pip install -e ".[extras]" from pyproject.toml. No [tool.uv] config, no CI uv lock --check, so the committed lock had drifted lean while a fresh uv lock resolves the full optional-extra tree (torch/CUDA/transformers). Removing it stops Dependabot's weekly regressive uv-lock PRs against an artifact that affects nothing. (Companion: Dependabot #24 closed, #23 download-artifact merged separately.)

Verification

  • Full suite: 2419 passed, 2 skipped (1 pre-existing unrelated warning)
  • ruff check src/ tests/: clean
  • +7 new tests (default-branch detection ×3, plan precedence ×2, executor edge cases ×2)

saagpatel added 5 commits June 6, 2026 06:14
…latest_path()

Introduce TRUTH_LATEST_FILENAME + truth_latest_path(output_dir) in
portfolio_truth_types (the domain leaf), and route all 19 path-join
sites + the glob through it. The filename now lives in one place
instead of being reconstructed across cli, serve/routes, report
enrichment, weekly command center, excel export, and the publisher.

Human-readable error/log copy and docstrings keep the literal as
prose. No behavior change.
The bounded-automation executor opened context-improvement PRs against a
hardcoded 'main' base. Detect each repo's actual default branch from the
local origin/HEAD ref (no network) in the truth-build pipeline, carry it
through IdentityFields, and resolve the PR base in precedence order:
explicit caller override > repo-detected default > portfolio fallback.

- portfolio_truth_sources: _git_default_branch() + thread through git facts
  (also DRYs _gather_git_facts' repeated dict construction)
- IdentityFields.default_branch: new optional field (additive, '' default)
- automation_workflow.build_context_pr_plan: resolve per-repo, '' = auto

Covered: origin/HEAD detection incl. multi-segment branches + unset
fallback; plan precedence (detected vs explicit override).
…ng PR URL)

Two edge cases in execute_context_pr:

- branch-orphan: when apply_change fails after 'git checkout -b', the
  executor returned to the default branch but left the created branch
  behind, so a retry hit 'branch already exists'. Now delete the orphan
  on rollback — the operation is retry-safe.

- empty execution_ref: when gh pr create succeeds (rc 0) with no URL on
  stdout, the proposal silently recorded an empty audit ref. The PR was
  created (re-running would duplicate it), so keep 'applied' but surface
  the missing URL in the detail instead of losing it silently.
Nothing reads this lockfile: every install path (ci.yml, audit.yml,
release.yml) uses `pip install -e ".[extras]"` resolved from
pyproject.toml. There is no [tool.uv] config and no CI `uv lock --check`,
so the committed lock had drifted lean while a fresh `uv lock` resolves
the full optional-extra tree (torch/CUDA/transformers).

Removing it stops Dependabot from opening regressive weekly uv-lock PRs
against an artifact that affects nothing. pip + pyproject is the real,
authoritative install path.
Review follow-up to eeb910c. The orphan-branch cleanup only worked when
apply_change failed without dirtying the tree. In the common case where
apply_change writes a partial file then raises, a plain checkout of the
default branch is blocked ('local changes would be overwritten'), its
unchecked returncode leaves HEAD on the orphan, and the orphan delete is
then refused ('currently checked out') — stranding the repo on the orphan,
the exact failure the cleanup targets.

Use a force checkout: the worktree is verified clean before apply_change
(skip-dirty rail), so it only discards apply_change's partial writes, then
the orphan deletes cleanly.
@saagpatel saagpatel merged commit 40ea5be into main Jun 6, 2026
3 checks passed
@saagpatel saagpatel deleted the chore/housekeeping-sweep branch June 6, 2026 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant