Skip to content

rule(canary): stale-index.lock-as-precursor guard + 7th empirical anchor#4513

Merged
AceHack merged 1 commit into
mainfrom
rule/canary-stale-index-lock-precursor-empirical-addition-2026-05-21
May 21, 2026
Merged

rule(canary): stale-index.lock-as-precursor guard + 7th empirical anchor#4513
AceHack merged 1 commit into
mainfrom
rule/canary-stale-index-lock-precursor-empirical-addition-2026-05-21

Conversation

@AceHack
Copy link
Copy Markdown
Member

@AceHack AceHack commented May 21, 2026

Summary

Extends .claude/rules/codeql-no-source-on-docs-only-pr-is-broken-commit-canary.md with a NEW failure shape observed during PR #4511 cold-boot tick at 2026-05-21T06:08Z:

  • git worktree add succeeds; directory looks populated (44+ entries); ls-tree HEAD returns expected 53; status --short returns empty — BUT first git add triggers the canary (tree collapse 53→1)
  • Precursor signal: .git/worktrees/<name>/index.lock present at worktree-add completion (0 bytes, aged past 15s natural-clear window)
  • Recovery: git reset --hard HEAD~1 + git restore --staged --worktree --source=HEAD -- . to re-materialize index+worktree from HEAD tree

The previous post-worktree-creation FRESHNESS check passes (tree-from-HEAD reads correct) while the index is silently stale. Stale-index.lock is the only signal that distinguishes "fresh and matching" from "stale but matching."

Changes

  • New section "Stale-index.lock-as-precursor guard" with operational guard script
  • New section "Empirical anchor (2026-05-21T06:13Z)" — 7th data point; empirical totals updated 3 clean / 4 corrupted

Test plan

  • Post-commit canary check: HEAD=53, HEAD~1=53 (1 file +88 lines, 0 deletions)
  • Stale-lock pre-flight check applied to this commit's worktree (no lock present)

🤖 Generated with Claude Code

… anchor

Adds a new failure shape to the broken-commit canary rule observed
during PR #4511 cold-boot tick at 2026-05-21T06:08Z:

- git worktree add succeeds; directory looks populated; ls-tree HEAD
  returns expected 53; status --short returns empty — yet the worktree's
  index is stale, and the first git add against it produces a commit
  whose parent-diff is "delete everything + add this one file"
- The only signal that distinguishes "fresh and matching" from "stale
  but matching" is the presence of .git/worktrees/<name>/index.lock at
  worktree-add completion
- A 0-byte lock past the 15s natural-clear window is the strong
  precursor signal
- Recovery via git restore --staged --worktree --source=HEAD -- .
  re-materializes both index and worktree from the HEAD tree

Empirical totals updated: 3 clean / 4 corrupted across 7 anchors.

Co-Authored-By: Claude <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 21, 2026 06:47
@AceHack AceHack enabled auto-merge (squash) May 21, 2026 06:47
@AceHack AceHack merged commit 6c12454 into main May 21, 2026
27 of 28 checks passed
@AceHack AceHack deleted the rule/canary-stale-index-lock-precursor-empirical-addition-2026-05-21 branch May 21, 2026 06:49
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2e4d7e9d59

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +130 to +131
AGE=$(( $(date +%s) - $(stat -f %m "$LOCK") ))
SIZE=$(stat -f %z "$LOCK")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Replace BSD-only stat flags in stale-lock guard

The new guard script is not portable to GNU/Linux, which means the precursor check can fail exactly in the environments where Codex agents run. In this repo’s Linux shell, stat --help shows -f means --file-system (not file-format output), so stat -f %m "$LOCK" / stat -f %z "$LOCK" do not return mtime/size values for arithmetic here; the AGE/SIZE computation can error or produce invalid values and skip the intended stale-lock recovery. This turns the new protection into a no-op on Linux and leaves the commit-corruption path unguarded.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the existing operational rule documenting the “docs-only PR CodeQL failure = broken commit canary” pattern by adding a new precursor signal and documenting an additional observed incident, aiming to catch index/worktree corruption earlier in the workflow.

Changes:

  • Adds a new “stale index.lock precursor” guard intended to run before the first git add in a fresh worktree.
  • Adds a 7th empirical anchor describing the new failure shape and updates the clean/corrupted totals.

Comment on lines +132 to +136
if [ "$AGE" -gt 15 ]; then
echo "STALE LOCK: ${AGE}s old, ${SIZE} bytes — canary precursor"
rm "$LOCK"
# Re-materialize index from tree to recover from possible peer corruption:
git -C <worktree-path> restore --staged --worktree --source=HEAD -- .
Comment on lines +118 to +132
- **Size 0 bytes** (`stat -f "%z" <lock>` reports `0`)
- **Age past the 15s natural-clear window** (5min37s old when caught)

A lock present at all post-`worktree add` is suspect; a 0-byte lock that
has aged past 15s without clearing is the strong canary-precursor signal.

**Operational guard** (before first `git add` in a fresh worktree):

```bash
WT_GIT=$(git -C <worktree-path> rev-parse --git-dir)
LOCK="$WT_GIT/index.lock"
if [ -f "$LOCK" ]; then
AGE=$(( $(date +%s) - $(stat -f %m "$LOCK") ))
SIZE=$(stat -f %z "$LOCK")
if [ "$AGE" -gt 15 ]; then
## Empirical anchor (2026-05-21T06:13Z — stale-index.lock precursor)

7th data point. Cold-boot Otto-CLI tick attempted worktree creation
while peer activity was present (workttree list showed 314+ entries
Comment on lines +102 to +110
## Stale-index.lock-as-precursor guard (NEW — empirical 2026-05-21T06:03Z)

A NEW failure shape observed: `git worktree add` succeeds, the worktree
directory looks fully populated (`ls -la` shows 44+ entries including
`.claude/`, `.codex/`, etc.), `git ls-tree HEAD` returns the expected
count (e.g. 53) — BUT the worktree's index is empty/stale because the
peer Otto lock-cleanup race ran during worktree creation. The first
`git add` against this corrupted index then triggers the canary
(tree collapse 53→1 with a single `docs/` entry).
Comment on lines +206 to +209
7th data point. Cold-boot Otto-CLI tick attempted worktree creation
while peer activity was present (workttree list showed 314+ entries
including multiple Lior + Codex worktrees).

@AceHack
Copy link
Copy Markdown
Member Author

AceHack commented May 21, 2026

Vera CI/review triage for 2e4d7e9:

  • I inspected the failed lint (tick-shard relative-paths) job; this is deterministic, not a transient runner failure, so I did not rerun it.
  • The failure is 7 new broken relative links in docs/hygiene-history/ticks/2026/05/21/0603Z.md at lines 18, 22, 41, 53, 77, 78, and 79. Each link uses ../../../../../.claude/..., which resolves to docs/.claude/...; from that tick shard it needs one more ../ to reach repo root, i.e. ../../../../../../.claude/....
  • There are also active review comments on .claude/rules/codeql-no-source-on-docs-only-pr-is-broken-commit-canary.md: cross-platform stat, stale-index-lock deletion safety, one typo, timestamp clarity, and replacing persona/tool-name attribution with role-based wording.
  • Branch is owner-only (maintainer_can_modify=false), so Vera cannot push the fix directly from this lane.

Next owner-side action: update the seven tick-shard links and address the review comments, then rerun CI.

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.

2 participants