Skip to content

memory(bare-main-ambiguity): generic automation rule — explicit refs required (Amara 2026-04-29)#775

Merged
AceHack merged 5 commits intomainfrom
memory/bare-main-ambiguity-automation-discipline-2026-04-29
Apr 29, 2026
Merged

memory(bare-main-ambiguity): generic automation rule — explicit refs required (Amara 2026-04-29)#775
AceHack merged 5 commits intomainfrom
memory/bare-main-ambiguity-automation-discipline-2026-04-29

Conversation

@AceHack
Copy link
Copy Markdown
Member

@AceHack AceHack commented Apr 29, 2026

Amara caught (via the autonomous-loop trace) that scripts were repeatedly hitting fatal: main matched multiple (2) remote tracking branches and continuing as if successful — producing wrong downstream working-tree state.

New durable memory file: generic rule applies to ANY repo with multiple remotes that have main (not just Zeta's LFG ↔ AceHack setup, since future-Claude might be dropped into recovery on a different multi-remote repo).

Best line: "Bare main is for humans. Automation uses explicit refs."

🤖 Generated with Claude Code

…Amara 2026-04-29 packet

Amara caught (via the 04:35Z+ trace) that autonomous-loop scripts
were repeatedly hitting 'fatal: main matched multiple (2) remote
tracking branches' and then continuing past the failure as if it
succeeded — which produced wrong downstream working-tree state.

Rule (generic, applies to ANY multi-remote repo, not just Zeta):
  Bare `main` is for humans.
  Automation uses explicit refs.

Zeta-specific worked example: refs/remotes/origin/main (LFG-trunk)
and refs/remotes/acehack/main (dev-mirror) both exist per the
zero-divergence-fork double-hop workflow. Different SHAs during
in-flight work is the normal state.

Local safety-belt set: `git config checkout.defaultRemote origin`
helps interactive use but is NOT a substitute for explicit refs in
scripts.

Per Aaron's note: future-Claude dropped into recovery on a
DIFFERENT repo with multiple remotes will hit the same failure
mode, so the memory file is framed generically with Zeta as worked
example.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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

Adds a new durable memory entry documenting a generic automation rule for multi-remote Git repos: avoid ambiguous bare branch names (especially main) and use explicit refs to prevent scripts from silently operating on the wrong base state after a failed checkout.

Changes:

  • Add new feedback memory describing the “bare main ambiguity” failure mode and recommending explicit refs in automation.
  • Update memory/MEMORY.md to index the new memory entry near the top (newest-first).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
memory/feedback_bare_main_ambiguity_automation_discipline_explicit_refs_required_amara_2026_04_29.md New memory file capturing the multi-remote main ambiguity failure mode and the explicit-ref automation rule.
memory/MEMORY.md Adds an index entry linking to the new memory file.

Comment thread memory/MEMORY.md Outdated
AceHack added a commit that referenced this pull request Apr 29, 2026
…n rule shard (#776)

Two more PRs merged (#771, #773 — 14 total this session arc).
PR #772 thread fixes (canonical-name consistency + softened catalog
claim). PR #775 opened with the generic bare-main-ambiguity memory
file (Amara packet). Branch creation now uses explicit
'git switch --detach refs/remotes/origin/main' per the new rule.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
…ections (PR #775)

Three Copilot findings on PR #775:
1. P1 internal inconsistency between 'never use bare main' rule and
   the local-main-tracking-origin example using 'git switch main'.
   Fixed by adding explicit explanation: bare 'git switch main' is
   safe ONLY when refs/heads/main exists locally and tracks origin
   (Git's lookup order finds the local ref first; the multi-remote
   guessing only fires when the bare name doesn't match a local
   ref). All other refs in the example reframed to fully-qualified
   refs/remotes/origin/main form.
2. P2 blank 'channel:' label — no actual frontmatter field; the
   line was prose continuation 'forwarded by Aaron through the
   maintainer channel:' and Copilot read it as a label. Removed
   the colon-style break by inlining: 'forwarded by Aaron through
   the maintainer channel (the live Claude Code CLI conversation
   surface):'.
3. P1 MEMORY.md entry too long — trimmed from full paragraph to
   one-liner per memory/README.md ~200-line cap discipline. The
   detailed content lives in the dedicated memory file.

Amara's round-2 packet additions:
- Hard-stop pattern (set -euo pipefail + explicit exit-1 on
  base-ref failure) — the actual bug Amara caught was 'fatal
  happened, loop continued', not just bare-main ambiguity.
- Better fetch refspec form (refs/heads/main:refs/remotes/origin/main)
  to ensure the remote-tracking ref is refreshed exactly.
- Pre-canonization search evidence section — recording the
  search terms used + the closest-hit non-fit so future-Claude
  can audit the search-before-canonizing decision.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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: fa88011c2f

ℹ️ 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".

AceHack added a commit that referenced this pull request Apr 29, 2026
…und-2 thread fixes shard (#778)

PR #776 merged. PR #775 round-2 fixes (internal consistency,
inlined channel-label misread, MEMORY.md trim, hard-stop pattern,
fetch refspec, pre-canonization search evidence). Amara's round-2
catch: the actual bug was continuing after fatal, not just
ambiguity.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
…+Gemini+Claude.ai+Alexa+Deepseek+Amara)

Four substantive additions to the bare-main rule + a stronger
distilled keeper:

1. **Defining 'stop the tick' (orchestrator vs shell-script
   distinction)**: set -euo pipefail is right for shells; the
   autonomous loop is an orchestrator that needs explicit
   failure propagation across multiple commands. Defines what
   'stop the tick' means: mark FAILED + minimal failure note +
   no commit/PR + wait for next cron cycle (preserves liveness
   while preventing fast-failure loops).

2. **Concurrency caveat for the fetch/switch pattern** (Claude.ai
   catch): the fetch+switch gives an explicit base ref but NOT a
   globally stable base across parallel ticks. For tick-history
   shards: fine. For stateful PR work: record the base SHA at
   branch-creation and verify before merge-sensitive operations.

3. **Generalized shell-glob lesson**: zsh-glob handling
   generalizes to ALL ref patterns in automation. Quote ref
   patterns so Git receives the pattern, not the shell's
   expansion.

4. **Future-consolidation threshold** (Claude.ai + Amara catch):
   when automation-failure-mode memory files reach 5-10 entries,
   create or update a consolidated index at
   docs/automation/automation-pitfalls.md. Substrate-locality >
   duplicate retrieval paths at the folder level too.

Stronger distilled keeper added:

  Topology is allowed.
  Ambiguity is expected.
  Continuing after fatal ambiguity is forbidden.

The actual immune trigger is the post-fatal continuation, not
the topology or the ambiguity — that's what makes this an
operational bug, not just multi-remote infrastructure.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

… explicit 'git switch refs/heads/main' (PR #775)

Codex correctly flagged that the 'with a local main tracking
origin' example used 'git switch main' (bare), which only works
AFTER refs/heads/main already exists locally. On first-run scripts
where the local branch hasn't been created yet, bare 'main' would
still hit the multi-remote ambiguity fatal.

Fix: use 'git switch refs/heads/main' explicitly. That form is
unambiguous regardless of local state — it asks Git for the
local-branch ref, never the remote-tracking namespace. Also
replaced 'git branch --track ... 2>/dev/null || true' with
'git branch -f main ...' for unconditional idempotent local
ref creation at the explicit start-point.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
AceHack added a commit that referenced this pull request Apr 29, 2026
…additions shard (#781)

Multi-AI packet (Ani+Gemini+Claude.ai+Alexa+Deepseek+Amara)
landed four substantive additions to PR #775 in one commit:
defining stop-the-tick (orchestrator vs shell semantics),
concurrency caveat for fetch/switch, generalized shell-glob
lesson, future-consolidation threshold.

Stronger distilled keeper: 'Topology is allowed. Ambiguity is
expected. Continuing after fatal ambiguity is forbidden.'

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
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: 96e7adfafa

ℹ️ 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".

AceHack added a commit that referenced this pull request Apr 29, 2026
…(PR #775 Codex P2 fix + #781 display-artifact) (#783)

PR #775 Codex P2 fix: bare 'git switch main' replaced with
'git switch refs/heads/main' (unambiguous regardless of local
state). Third round of refinement on the bare-main rule —
each round caught a real edge case.

PR #781 same display-artifact thread as #760/#777; resolved
not-actionable.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
…e 'git switch main' (Codex round-4 P1)

Codex correctly flagged that 'git switch refs/heads/main' (non-
detached form) is invalid: git switch in non-detached mode takes
a branch NAME, not a fully-qualified ref.

The correct sequence (which the original draft had right; my
round-3 fix overcorrected):

1. git fetch origin refs/heads/main:refs/remotes/origin/main
2. git branch -f main refs/remotes/origin/main   ← creates local
   branch at explicit ref FIRST (eliminating ambiguity)
3. git switch main                                ← safe NOW because
   refs/heads/main exists; lookup-order finds local ref first

Updated explanation to cover the three valid switch forms:
- git switch <name>            non-detached, branch-name only
- git switch --detach <ref>    detached HEAD, accepts any ref
- git checkout <name>          older form, same ambiguity concerns

For new feature branches: git switch --detach refs/remotes/origin/main
+ git switch -c <new-branch>.

This is round 4 of refinement on the bare-main rule — Codex
caught my own overcorrection. Each round catches a real edge
case the prior round missed.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 29, 2026 05:16
AceHack added a commit that referenced this pull request Apr 29, 2026
…erged, 23 total session arc) (#784)

PR #780, #781, #782 squash-merged onto main. 23 PRs total this
session arc. Only PR #775 (bare-main rule) and PR #783 (last
tick's shard) still open.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
@AceHack AceHack merged commit d5922d5 into main Apr 29, 2026
27 checks passed
@AceHack AceHack deleted the memory/bare-main-ambiguity-automation-discipline-2026-04-29 branch April 29, 2026 05:19
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: ea131771ff

ℹ️ 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 +171 to +172
git fetch acehack main --quiet
git switch --detach refs/remotes/acehack/main
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 Fetch AceHack main with explicit destination refspec

The AceHack snippet fetches with git fetch acehack main and then checks out refs/remotes/acehack/main, but this form can leave refs/remotes/acehack/main stale because the command-line refspec updates FETCH_HEAD while remote-tracking updates still depend on remote.acehack.fetch mapping. In repos with narrowed/custom fetch refspecs, the next git switch --detach refs/remotes/acehack/main can branch from an old commit, recreating the wrong-base-state failure this memo is trying to prevent.

Useful? React with 👍 / 👎.

Comment on lines +130 to +133
# Create the local tracking branch unconditionally at the
# explicit ref (-f forces update if it already exists;
# explicit start-point removes any guessing):
git branch -f main refs/remotes/origin/main
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Guard git branch -f main when main is checked out

This sequence is described as creating/updating local main “unconditionally”, but git branch -f main ... fails with fatal: cannot force update the branch 'main' used by worktree when the current branch is already main. In automation that uses set -e, that aborts the flow before the subsequent git switch main, so the documented recovery path is brittle for a common starting state.

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comment on lines +129 to +137
git fetch origin refs/heads/main:refs/remotes/origin/main --quiet
# Create the local tracking branch unconditionally at the
# explicit ref (-f forces update if it already exists;
# explicit start-point removes any guessing):
git branch -f main refs/remotes/origin/main
# Now bare `git switch main` is safe because refs/heads/main
# exists locally and matches first in Git's lookup order:
git switch main || { echo "failed to switch to local main"; exit 1; }
git reset --hard refs/remotes/origin/main
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

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

In the "local main branch tracking origin" snippet, the earlier section emphasizes hard-stopping on base-ref setup failures, but this snippet doesn’t enable strict mode (set -euo pipefail) or otherwise check git fetch / git branch -f for failure. As written, a failed fetch/update could still allow the script to continue on a stale base ref. Consider either adding strict mode at the top of this snippet or adding explicit || exit checks (and/or a note that the snippet assumes strict mode is already enabled).

Copilot uses AI. Check for mistakes.
**Branch off AceHack main**:

```bash
git fetch acehack main --quiet
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

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

The AceHack example fetches main but then detaches from refs/remotes/acehack/main. Depending on the remote’s fetch refspec configuration, git fetch acehack main may only update FETCH_HEAD and leave refs/remotes/acehack/main stale, which would defeat the “explicit base ref” goal. Consider using an explicit refspec here as well (mirroring the origin example) so refs/remotes/acehack/main is guaranteed to be refreshed before switching.

Suggested change
git fetch acehack main --quiet
git fetch acehack refs/heads/main:refs/remotes/acehack/main --quiet

Copilot uses AI. Check for mistakes.
AceHack added a commit that referenced this pull request Apr 29, 2026
…d + bare-main round-4 fix) (#785)

PR #783 merged. PR #775 round-4 fix: Codex P1 caught my round-3
overcorrection ('git switch refs/heads/main' is invalid for
non-detached mode). Reverted to bare 'git switch main' AFTER
ensuring local ref exists via 'git branch -f main ...'.

24 PRs total this session arc.

New recurring-fix-class meta-entry: agent-overcorrection-thread
(a fix from earlier itself becomes the bug in a later finding).

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
AceHack added a commit that referenced this pull request Apr 29, 2026
…erge (#786)

PR #784 squash-merged. 25 PRs total this session arc. Queue depth
stabilized at 2 PRs (#775 + #785). Steady-state operational drain.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
AceHack added a commit that referenced this pull request Apr 29, 2026
… (26 PRs total session arc) (#787)

PR #775 squash-merged at 05:19:23Z after 4 rounds of refinement
(Amara initial + multi-AI synthesis packet + Codex P2 + Codex P1
catching my round-3 overcorrection). 26 PRs total this session
arc.

Best keeper: 'Topology is allowed. Ambiguity is expected.
Continuing after fatal ambiguity is forbidden.'

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
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