Skip to content

Reuse trusted workflow content during source waits - #1525

Merged
mergify[bot] merged 1 commit into
mainfrom
lean178/1491-wait-workflow
Nov 26, 2026
Merged

mergify[bot] merged 1 commit into
mainfrom
lean178/1491-wait-workflow

Conversation

@eowca

@eowca eowca commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Reuse trusted workflow content during source waits

Context and goal

  • Goal: Avoid rereading and parsing the same immutable trusted workflow on each poll.
  • Problem: A 12-observation pending wait read the same commit-qualified workflow 12 times.
  • Context: The existing config snapshot is already scoped to this invocation. Reuse it only after Git confirms the same branch and revision.

Closes #1491

Acceptance

  • Stable source-wait observations resolve the trusted ref and commit each time but read its workflow blob once.
  • Configured overrides, detectably different policy, a ref move, and a base advance preserve existing validation and diagnostics.
  • No new persistent state or net test lines.

Validation evidence

The 12-observation fixture went from 41 Git commands and 12 workflow blob reads to 30 Git commands and one workflow blob read. Across 15 interleaved runs, median handler time fell from 103.72 ms to 85.71 ms. Focused wait tests passed with zero net test lines, and manual loose and packed replacement-ref cases still loaded the effective workflow.

Base

Base: a68ef3b

Validation

Recorded for f0085ec293c2

  • uv run --group dev ruff check src tests: exit 0
  • uv run --group dev tach check: exit 0
  • uv run --python 3.14 python scripts/check_architecture_docs.py: exit 0
  • scripts/size_budget.sh: exit 0
  • uv run --group dev pytest -q: exit 0

Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Review

  • primary, claude, f0085ec, approve

Co-Authored-By: Codex <noreply@openai.com>

@loopzero-feder-positronics loopzero-feder-positronics Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loopzero primary review by claude on f0085ec293c21045e996fe4aa63a368e30149e31, 55.2s: approve (0 critical, 0 important, 3 suggestion)

Settings per native call (launch configuration and CLI claims, not backend attestation):

  • Call 1: requested model claude-opus-5-5 (effort medium); CLI-reported model claude-opus-5-5 (effort unknown); configured model claude-opus-5-5 (effort medium)

Native Claude output is retained in the restricted local review receipt.

Comment thread tests/test_cli.py
monkeypatch.setattr(cli, "_sleep", lambda _: None)
code, out, err = run(capsys, "ready", "--wait")

assert sum(call[0] == "show" and call[-1].endswith(":workflow.toml") for call in git_calls) == 1

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Inline workflow-read count duplicates existing assert_git_cost helper

The new assertion reimplements the show ... :workflow.toml counting predicate already defined in assert_git_cost (tests/test_cli.py:306-308). If the predicate ever changes (for example, the blob read moves to cat-file), the two copies will drift apart. Factor the predicate into a small shared helper that both call sites use, or use assert_git_cost(git_calls, <total>, 1). Pinning the total would also lock in the claimed reduction from 41 to 30 Git commands, which the current test does not check.

Comment thread src/loopzero/config.py


def _remote_workflow(worktree: Path, branch: str) -> tuple[Config, str]:
def _has_replacement_refs(common_dir: Path) -> bool:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Replacement-ref guard and cache-miss paths have no automated coverage

_has_replacement_refs is a new hand-written probe of Git's on-disk layout: the loose refs/replace directory, reftable, and packed-refs. The only evidence for it is the manual check described in the task. No test runs the loose or packed replacement case, a ref move between polls, or the two-branch setup where origin/HEAD differs from repo.base. If this guard regresses, the waiter could quietly keep using a stale parsed policy, and nothing would catch it. Two cheap tests would close the gap: one that writes a refs/replace/<sha> line to packed-refs, and one that moves origin/<base> between polls, each asserting that the workflow blob is read again. Those tests would add lines, which conflicts with the no-net-test-lines goal, so this is non-blocking.

Comment thread src/loopzero/config.py
)
branch = ref.removeprefix(prefix)
policy, revision = _remote_workflow(worktree, branch)
policy, revision = _remote_workflow(worktree, branch, previous)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Split default/base configuration still rereads the default branch workflow every poll

previous holds the policy from the base branch. When origin/HEAD points at a different branch than repo.base, the first _remote_workflow(worktree, branch, previous) call fails previous.base_branch == branch, so it runs git show and parses the default branch's workflow on every poll. That is correct, just not cached. In this setup the wait still makes one blob read per poll instead of one in total. If that setup matters, the cache would need to key on the default branch's revision as well. Otherwise, note in ARCHITECTURE.md that reuse only covers the base workflow.

@eowca
eowca marked this pull request as ready for review November 26, 2026 06:59
@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

@Mergifyio queue

@mergify

mergify Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

✅ Merged into main as 6307f59 at 07:08 UTC

8 min in the queue, 4 min of it CI.

So far

  • ✅ Entered the queue Thu 26 Nov, 07:00 · rule main · triggered by @eowca with the @mergifyio queue command
  • ✅ Passed · draft #1581
  • ✅ Merged 07:08 · 6307f59 · squash
3 merge conditions met
  • github-review-approved · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required
  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-success = checks
    • check-neutral = checks
    • check-skipped = checks
  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-success = Loop-zero Eligibility
    • check-neutral = Loop-zero Eligibility
    • check-skipped = Loop-zero Eligibility

Times in UTC · dashboard · how the merge queue works

@mergify mergify Bot added the queued label Nov 26, 2026
@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

No description provided.

@mergify
mergify Bot merged commit 6307f59 into main Nov 26, 2026
18 checks passed
@mergify mergify Bot removed the queued label Nov 26, 2026
@eowca
eowca deleted the lean178/1491-wait-workflow branch November 26, 2026 07:09
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.

Reuse the trusted workflow blob on unchanged source-wait polls

1 participant