fix(deliver): name both first-push errors #222

Merged
claudiomaradonna merged 1 commit from fix/first-push-errors into main 2026-11-12 15:29:52 +01:00
Collaborator

Why

Agent Foundry gives coding agents their working rules as skills; the
deliver skill's land.md tells an agent how to push a finished
branch. Under Claude Code's sandbox, which keeps git's configuration
read-only, a branch's first push lands and then prints two errors.
land.md named only the second, so an agent met a
could not lock config file error the skill did not foresee and had to
confirm the push by other means. The branch was also left without an
upstream, and nobody told the user: the sentence on it sits in
docs/SANDBOX.md, which a repository that adopts Agent Foundry does not
receive. It happens on every first push from the sandbox.

Pushing without -u inside the sandbox was set aside: it gives the same
outcome, and the agent would have to tell whether the sandbox is on
before pushing. Pushing always without -u was set aside because
branches pushed outside the sandbox would lose their upstream.

Closes #219

What changed

Before, an agent reading land.md knew one of the two errors and went
on without a word about the upstream. Now the item quotes both errors,
and when the push prints them the agent goes on and tells the user that
the branch has no upstream, with the command that sets it outside the
sandbox. The command names the branch, so it works from any checkout.

The push itself stays git push -u <remote> <branch>. The change is in
the first item of .agents/skills/deliver/land.md, and the first-push
test of tests/agent-config/real-source.sh now also checks that
land.md quotes each error git prints.

How to verify

  1. Have Git 2.48 or later and a shell.

  2. The problem. A read-only config, as the sandbox holds it, is an empty
    .git/config.lock:

    git init -q --bare /tmp/trial-remote.git
    git init -q /tmp/trial && cd /tmp/trial
    git -c user.name=Test -c user.email=test@example.invalid \
      commit -q --allow-empty -m base
    git remote add origin ../trial-remote.git
    git switch -q -c topic
    : > .git/config.lock
    git push -u origin topic
    git config --get branch.topic.remote
    

    The push creates the branch, then prints
    error: could not lock config file .git/config: File exists and
    error: unable to write upstream branch configuration, and the last
    command prints nothing. In a clone of this repository, main does
    not name the first error:

    git fetch origin
    git grep -c 'could not lock config file' origin/main -- \
      .agents/skills/deliver/land.md
    

    prints nothing.

  3. The solution. The same search on the branch:

    git grep -c 'could not lock config file' \
      origin/fix/first-push-errors -- .agents/skills/deliver/land.md
    

    prints origin/fix/first-push-errors:.agents/skills/deliver/land.md:1,
    and the item's command, git branch --set-upstream-to=origin/topic topic, run in /tmp/trial after rm .git/config.lock, sets the
    upstream.

The checks of docs/MAINTENANCE.md pass on the tip, and the extended
first-push test fails on main with land.md quotes no part of: error: could not lock config file .git/config: File exists.

Not tried: an agent delivering a branch in a trial repository under the
sandbox with the new text, which needs a session of its own; and the
last command of step 3, which was not run.

Considerations

docs/SANDBOX.md keeps its own sentence on this push for developers,
since land.md is the only copy an adopting repository's agents have.

## Why Agent Foundry gives coding agents their working rules as skills; the `deliver` skill's `land.md` tells an agent how to push a finished branch. Under Claude Code's sandbox, which keeps git's configuration read-only, a branch's first push lands and then prints two errors. `land.md` named only the second, so an agent met a `could not lock config file` error the skill did not foresee and had to confirm the push by other means. The branch was also left without an upstream, and nobody told the user: the sentence on it sits in `docs/SANDBOX.md`, which a repository that adopts Agent Foundry does not receive. It happens on every first push from the sandbox. Pushing without `-u` inside the sandbox was set aside: it gives the same outcome, and the agent would have to tell whether the sandbox is on before pushing. Pushing always without `-u` was set aside because branches pushed outside the sandbox would lose their upstream. Closes #219 ## What changed Before, an agent reading `land.md` knew one of the two errors and went on without a word about the upstream. Now the item quotes both errors, and when the push prints them the agent goes on and tells the user that the branch has no upstream, with the command that sets it outside the sandbox. The command names the branch, so it works from any checkout. The push itself stays `git push -u <remote> <branch>`. The change is in the first item of `.agents/skills/deliver/land.md`, and the first-push test of `tests/agent-config/real-source.sh` now also checks that `land.md` quotes each error git prints. ## How to verify 1. Have Git 2.48 or later and a shell. 2. The problem. A read-only config, as the sandbox holds it, is an empty `.git/config.lock`: ```bash git init -q --bare /tmp/trial-remote.git git init -q /tmp/trial && cd /tmp/trial git -c user.name=Test -c user.email=test@example.invalid \ commit -q --allow-empty -m base git remote add origin ../trial-remote.git git switch -q -c topic : > .git/config.lock git push -u origin topic git config --get branch.topic.remote ``` The push creates the branch, then prints `error: could not lock config file .git/config: File exists` and `error: unable to write upstream branch configuration`, and the last command prints nothing. In a clone of this repository, `main` does not name the first error: ```bash git fetch origin git grep -c 'could not lock config file' origin/main -- \ .agents/skills/deliver/land.md ``` prints nothing. 3. The solution. The same search on the branch: ```bash git grep -c 'could not lock config file' \ origin/fix/first-push-errors -- .agents/skills/deliver/land.md ``` prints `origin/fix/first-push-errors:.agents/skills/deliver/land.md:1`, and the item's command, `git branch --set-upstream-to=origin/topic topic`, run in `/tmp/trial` after `rm .git/config.lock`, sets the upstream. The checks of `docs/MAINTENANCE.md` pass on the tip, and the extended first-push test fails on `main` with `land.md quotes no part of: error: could not lock config file .git/config: File exists`. Not tried: an agent delivering a branch in a trial repository under the sandbox with the new text, which needs a session of its own; and the last command of step 3, which was not run. ## Considerations `docs/SANDBOX.md` keeps its own sentence on this push for developers, since `land.md` is the only copy an adopting repository's agents have.
fix(deliver): name both first-push errors
Some checks failed
Maintenance / checks (push) Has been cancelled
Maintenance / checks (pull_request) Successful in 4m32s
f09814c7ba
Inside Claude Code's sandbox the first push lands and prints two
errors, of which land.md named one, and it left the branch's missing
upstream unsaid. An adopting repository has no docs/SANDBOX.md to say
it, so the agent now tells the user, with a command that names the
branch and so works from any checkout.

Refs: #219
claudiomaradonna deleted branch fix/first-push-errors 2026-11-12 15:29:56 +01:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
claudiomaradonna/agent-foundry!222
No description provided.