Skip to content

Commit a4669e8

Browse files
dougborgclaude
andcommitted
docs: address second Copilot review on #716 — __init__.py + accurate git push behavior
Two valid Copilot findings: 1. **`__init__.py` missing from regeneration summary**: verified by reading `scripts/regenerate_client.py:347` — `move_client_to_workspace` writes a fixed flattened-import template to `katana_public_api_client/__init__.py` on every regen, overwriting whatever was there. The inline comment in the script says "preserve any custom content" but the code doesn't merge — it just writes the template. Added `__init__.py` to the rewritten-paths list with a parenthetical flagging the misleading comment so contributors don't put hand-maintained exports there expecting them to survive. 2. **Inaccurate `git push -u origin <branch>` rationale**: Copilot is right that `git push -u origin <branch-name>` with an explicit branch-name refspec creates/updates `refs/heads/<branch-name>` on the remote — it's safe by itself. The trap the rule guards against is under-specified pushes (bare `git push`, `git push -u origin` without a refspec, or commands routed by `push.default = upstream`) that resolve to the tracked upstream, which can be `main` if the branch was created via `git checkout -b <name> origin/main`. Reworded both the CONTRIBUTING walkthrough and the canonical COMMIT_STANDARDS "First-Push Safety" section so the rationale is technically accurate: the value of `HEAD:refs/heads/<name>` is removing dependence on `push.default`, branch-tracking config, and shell habits — not overriding refspec resolution that's already correct in the safe case. Kept the incident reference (commit `30f3fd86` reached main, tagged, and published before cancellation) in COMMIT_STANDARDS so the rule's history is preserved. Refs #569. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 808566f commit a4669e8

2 files changed

Lines changed: 29 additions & 16 deletions

File tree

.github/agents/guides/shared/COMMIT_STANDARDS.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -301,21 +301,29 @@ commit anyway, so bundling is always the right call.
301301
## First-Push Safety
302302

303303
When a local branch was created via `git checkout -b <name> origin/main`, its upstream
304-
is set to `origin/main`. A subsequent `git push -u origin <name>` then resolves to its
305-
tracked upstream and **pushes the local tip straight to `main`** — bypassing PR review
306-
and triggering semantic-release.
304+
is set to `origin/main`. A subsequent under-specified push (bare `git push`, or
305+
`git push -u origin` with no refspec, or commands implicitly affected by
306+
`push.default = upstream`) can resolve to that tracked upstream and **push the local tip
307+
straight to `main`** — bypassing PR review and triggering semantic-release.
307308

308-
**Always use the explicit destination ref for first-time pushes:**
309+
Even though `git push -u origin <branch-name>` with an explicit branch-name refspec *is*
310+
safe by itself, relying on it requires every contributor's git config and push habits to
311+
stay consistent forever. One stray `git config --global push.default upstream` or a
312+
muscle-memory bare `git push` is all it takes.
313+
314+
**Always use the fully explicit destination ref for first-time pushes:**
309315

310316
```bash
311-
# Wrongpushes to whatever the local branch tracks (may be main)
317+
# Riskydepends on push.default, branch tracking, and contributor habits
312318
git push -u origin chore/foo
313319

314-
# Rightexplicit destination, creates the remote branch
320+
# Safenames both source (HEAD) and destination ref explicitly
315321
git push -u origin HEAD:refs/heads/chore/foo
316322
```
317323

318-
A `pre-push` hook enforces this; **do not bypass with `--no-verify`**.
324+
This actually happened: commit `30f3fd86` reached main + tagged `mcp-v0.44.1` +
325+
published to PyPI before the pipeline could be cancelled. A `pre-push` hook now enforces
326+
the explicit form on every contributor's machine; **do not bypass with `--no-verify`**.
319327

320328
## Multi-Package Changes
321329

docs/CONTRIBUTING.md

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,17 +122,20 @@ All formatting is automated via `uv run poe format`.
122122

123123
1. **Push to your fork** and create a pull request
124124

125-
For the first push of a new branch, use the explicit destination ref to avoid a bare
126-
`git push -u origin <name>` resolving to the local branch's tracked upstream (which
127-
may still be `main` if you created the branch via
128-
`git checkout -b <name> origin/main`) and pushing your tip straight to `main`:
125+
For the first push of a new branch, use the explicit destination ref so the push
126+
doesn't depend on `push.default`, upstream-tracking config, or shell habits:
129127

130128
```bash
131129
git push -u origin HEAD:refs/heads/feat/your-feature-name
132130
```
133131

134-
A pre-push hook enforces this; never bypass with `--no-verify`. Full rationale + the
135-
incident that prompted the rule live in
132+
The form `HEAD:refs/heads/<name>` names both the source (current HEAD) and the
133+
destination ref explicitly, so it's immune to git configs (e.g.
134+
`push.default = upstream`) that can reroute an under-specified push to whatever the
135+
branch tracks — which, if you created the branch via
136+
`git checkout -b <name> origin/main`, is `main`. A pre-push hook enforces the
137+
explicit form; never bypass with `--no-verify`. Full rationale + the incident that
138+
prompted the rule live in
136139
[COMMIT_STANDARDS "First-Push Safety"](../.github/agents/guides/shared/COMMIT_STANDARDS.md#first-push-safety).
137140

138141
### Commit Message Format
@@ -321,9 +324,11 @@ sync with the actual generators:
321324
If the docs and either script ever disagree, the script wins.
322325

323326
The high-level rule: anything under `api/`, `models/`, `client.py`, `client_types.py`,
324-
`errors.py`, `py.typed`, and `models_pydantic/_generated/` (plus `_auto_registry.py`) is
325-
rewritten on every regen. Everything else under `katana_public_api_client/` (including
326-
the rest of `models_pydantic/` — hand-maintained pydantic infrastructure) is preserved.
327+
`errors.py`, `py.typed`, `__init__.py` (rewritten from a flattened-import template every
328+
regen — *not* preserved despite the inline comment in the script suggesting otherwise),
329+
and `models_pydantic/_generated/` (plus `_auto_registry.py`) is rewritten on every
330+
regen. Everything else under `katana_public_api_client/` (including the rest of
331+
`models_pydantic/` — hand-maintained pydantic infrastructure) is preserved.
327332

328333
### Regeneration Features
329334

0 commit comments

Comments
 (0)