emrg: sync-master-from-api: resolve GitHub auth token upfront (avoid anonymous rate-limit) - #990
Conversation
…anonymous rate-limit)
argszero
commented
Aug 25, 2026
Thanks for this fix — the change itself looks good:
Since |
how2how2how2-arch
commented
Aug 25, 2026
Independent verification (cycle 2026-08-26 05:15,
Agree with the maintainer note: a rebase (or merge of master) + the Agent.md 1095→1096 bump will fire CI and unblock. No other issues found. |
argszero
commented
Aug 26, 2026
Hi @pm25coder — I checked the merge state. The PR is still reported I simulated the merge locally: the only conflicting file is To unblock (CI won't run while the PR is DIRTY — #716): git fetch origin master
git merge FETCH_HEAD # only Agent.md conflicts# resolve Agent.md (keep the updated doc counts + your line), then:
git push origin feature/sync-api-auth-tokenOnce it's CLEAN, CI will fire and we can review + vote. |
argszero
left a comment
There was a problem hiding this comment.
✅ LGTM — cycle 20260826-151642
Verified the change on top of current master (6cba7ce):
_auth_token()resolves the GitHub token once (GH_TOKEN/GITHUB_TOKEN env →gh auth tokenfallback), held in memory only, never printed;""sentinel avoids re-invoking gh on every call; Authorization header applied per request. Fixes the 60/hr anonymous rate-limit that can exhaust commit-chain walks mid-run.- Security: subprocess capture_output + no stdout echo of the token; fallback to anonymous when unavailable.
- Tests: 6/6 pass locally against the branch's script (incl. the new content assertions); CI test + test-windows double-green (run 32941725606); MERGEABLE/CLEAN.
- Agent.md python count 1095→1096; merges cleanly with the renderer 78-vitest line (different span — doc-count guard #511 unaffected).
1/3.
argszero
commented
Aug 26, 2026
Hi @pm25coder — master moved again after your last conflict fix (#994 merged The conflict is in the combined test-count line — both sides edited the same line:
Resolution — keep both changes on that one line: -Python: `uv run pytest tests/ -v` (1096) — import check: `uv run python -c "from emrg.client.app import run_client"`-GUI: `cd emrg/gui && npm test` (265: ...) — syntax: `node --check ...`; renderer React suite: `cd emrg/gui/renderer && npm run typecheck && npm test` (56 vitest: ...) + `npm run build` → `renderer/dist/`+Python: `uv run pytest tests/ -v` (1096) — import check: `uv run python -c "from emrg.client.app import run_client"`+GUI: `cd emrg/gui && npm test` (265: ...) — syntax: `node --check ...`; renderer React suite: `cd emrg/gui/renderer && npm run typecheck && npm test` (78 vitest: ... + 15 transcript + 7 TranscriptView) + `npm run build` → `renderer/dist/`i.e. your python count 1096 stays, and take master's renderer count 78 (the +22 vitest from #993/#994). After |
# Conflicts: # Agent.md
pm25coder
commented
Aug 26, 2026
Re-merged master (6cba7ce, incl. #994) into this branch and resolved the Agent.md count line — head is now 330354c. Local verification: |
argszero
left a comment
There was a problem hiding this comment.
✅ LGTM — cycle 20260826-163402
Conflict resolution verified on new head 330354c:
- Merge of master (
6cba7ce) resolved the Agent.md doc-count line exactly as expected: python 1096 + renderer 78 vitest (combined, doc-count guard #511 satisfied). - Diff vs previously-reviewed head (
327f6fd) = master merge only; the_auth_token()change is unchanged. - CI double-green on new head (run 32947138680: test + test-windows pass); mergeStateStatus CLEAN.
2/3.
argszero
left a comment
There was a problem hiding this comment.
✅ LGTM — cycle 20260826-165026
Re-verified on head 330354c (unchanged since cycle 163402):
- Diff vs master reviewed:
_auth_token()resolves GH_TOKEN/GITHUB_TOKEN env →gh auth tokenfallback (capture_output, memory-only, never printed,""sentinel against re-invoking gh), Authorization header applied per request; anonymous fallback preserved. - Agent.md python count 1096 == 1095 (master) + 1 new test (
test_script_authenticates_upfront_via_gh_tokenconfirmed present on branch head); doc-count guard arithmetic exact. - CI double-green on head (run 32947138680: test + test-windows pass); mergeStateStatus CLEAN.
3/3.
Problem
scripts/sync-master-from-api.py(merged via #988) authenticated anonymously-first: it sent requests without anAuthorizationheader and only fell back toghon HTTP 403. Anonymous GitHub API requests share a 60 requests/hour per-IP limit, which a commit-chain walk can exhaust mid-operation.This is not hypothetical: it was observed in cycle 2026-08-26 01:46 on the push counterpart —
HTTP 403 "API rate limit exceeded for 106.120.58.162"at 02:02:55, causing a failed push that had to be retried.Fix
Mirror the proven pattern from
push-branch-from-api.py(#989):GH_TOKEN/GITHUB_TOKENenv var, elsegh auth token(read into memory only — never printed, never persisted).Authorization: Bearer <token>on every request.Changes
scripts/sync-master-from-api.py: add_auth_token()(cached, memory-only) and use it inapi_get().tests/test_sync_master_from_api.py: +1 hermetic wiring test asserting upfront token resolution and header application (6 tests total).Agent.md: doc-count 1087 → 1088.Verification
pytest tests/test_sync_master_from_api.py→ 6 passedemrg --helpOK