Skip to content

fix(context): single-source modelwindow table + add claude-sonnet-5 (gc-qin3c)#100

Open
zook-bot wants to merge 8 commits into
mainfrom
fix/gc-qin3c-modelwindow-sonnet5-sync
Open

fix(context): single-source modelwindow table + add claude-sonnet-5 (gc-qin3c)#100
zook-bot wants to merge 8 commits into
mainfrom
fix/gc-qin3c-modelwindow-sonnet5-sync

Conversation

@zook-bot

Copy link
Copy Markdown

Summary

Brings the fork's core-path context-window resolver up to the reviewed form of upstream PR gastownhall#4527 (gc-z0vi2, head 5a9daff84).

The fork already carries the single-source internal/modelwindow extraction from #85 (gc-os8fn), but that landed before the upstream review and trails it in two ways:

  1. Functional gap: the 1M marker list is missing claude-sonnet-5. A bare claude-sonnet-5 — a 1M-context model — resolves to the 200K default on both the API/session-log path (internal/sessionlog.ModelContextWindow) and the context-pressure injector (cmd/gc/context_inject.go). That is the same under-report class ModelContextWindow under-reports 1M window for bare claude-opus-4-8 (no [1m] suffix) — context_pct reads 100% at real ~38% (gc-os8fn) #85 fixed for the bare opus-4-6/4-7/4-8 and sonnet-4-6 families, left open for the newer model.
  2. Shape drift: ModelContextWindow under-reports 1M window for bare claude-opus-4-8 (no [1m] suffix) — context_pct reads 100% at real ~38% (gc-os8fn) #85 used a familyWindows map plus a separate familyOrder slice; the reviewed PR folds them into one ordered struct slice (longest-match-first inline), and expands the tests.

This PR checks out the five fork-relevant files from the reviewed PR commit 5a9daff84, making them byte-identical to it:

  • internal/modelwindow/modelwindow.go
  • internal/modelwindow/modelwindow_test.go
  • internal/sessionlog/context.go
  • internal/sessionlog/context_test.go
  • cmd/gc/context_inject_test.go

cmd/gc/context_inject.go and internal/modelwindow/testenv_import_test.go were already identical on fork main and are untouched.

Deliberately excluded

The upstream PR also touches two CI-shape-specific files that must not cross onto the fork base:

  • .github/workflows/ci.yml
  • scripts/cipolicy/policy.go (the expectedCIExecutionHash / requiredFilterPaths)

The fork carries its own CI workflow and cipolicy execution digest; overwriting them with upstream's values would break the fork's own policy check. The fork's cipolicy already covers internal/modelwindow/** (landed with #85), so no policy change is needed here.

Behavior

  • bare opus-4-6/4-7/4-8, sonnet-4-6, sonnet-5, fable, mythos → 1M
  • the [1m] suffix still forces 1M for any Claude family
  • older/unknown Claude families keep the 200K default
  • unknown families return 0 so each caller applies its own policy

No behavior change for any family already recognized on fork main; the only newly-resolved model is claude-sonnet-5.

Testing

Bead: gc-qin3c (discovered-from gc-z0vi2).

zook-bot added 8 commits July 22, 2026 19:09
…gc-yey06) (#88)

Only unassigned routed work is pool demand, so a bare 'gc sling <pool> <bead>'
of an existing open bead must clear a stale assignee or the re-pour is
invisible to scale_check and stalls silently. In-progress beads are exempt.

The order-sweep rig-dir stat gate that originally rode along in this commit
was dropped: all configured rigs exist on disk, so it guarded a condition
that does not occur, at the cost of threading an io.Writer through 3 call
sites.
…olated git config (gc-v2z1p) (#89)

`make check` runs `go test -p=4 ./...`; the parallel link phase of
several large CGO/ICU test binaries peaks past the 16G tmpfs-backed
/tmp and fails mid-link with "No space left on device". This surfaces
as spurious rebase/refinery preflight failures (first hit hard by the
gc-k0hvd upstream-rebase polecat, which worked around it by pointing
TMPDIR at ext4). The flake is latent and recurs under load whenever
/tmp is tight.

Root cause: the TEST_ENV `env -i` wrapper passed TMPDIR through with a
/tmp default, and GOTMPDIR is empty, so the Go toolchain's build/link
work dir (go-build*/go-link*) and test-runtime temp both land on the
tmpfs.

Fix: default the wrapper's TMPDIR to /var/tmp (a persistent, non-tmpfs
disk with more room; ext4 with 66G free on the Gas City host) instead
of /tmp. Every `make test*` target flows through TEST_ENV, so the
shard/parallel helper scripts it invokes inherit the same TMPDIR — one
leverage point covers all preflight paths. An explicit TMPDIR export
still overrides (e.g. `TMPDIR=/tmp make check`), so callers that want
the old behavior keep it.

Validation (fixed env, TMPDIR unset):
- `go build -work` reports WORK=/var/tmp/go-build... (was /tmp)
- a built binary sees os.TempDir()=/var/tmp
- with TMPDIR=/tmp exported, WORK returns to /tmp/go-build... (override
  preserved)
- `make -n test` expands the recipe with TMPDIR="${TMPDIR:-/var/tmp}"

Environment/infra fix, not a code regression. No behavior change for
tests themselves — they use whatever os.TempDir() returns.

Second host-state leak, same wrapper: TEST_ENV allowlists HOME but not
SSH_AUTH_SOCK, so a host ~/.gitconfig with commit.gpgsign=true plus
gpg.format=ssh made every test that execs `git commit` fail with
"Couldn't get agent socket?" / "failed to write commit object". That was
being patched per-test by sprinkling testutil.IsolatedGitConfig(t) into
upstream-owned test files — carry that grew with every new upstream test
that execs git.

Fix: point GIT_CONFIG_GLOBAL at a seeded config and GIT_CONFIG_SYSTEM at
/dev/null in the same wrapper, so every test binary inherits the
isolation and no per-test opt-in is needed. The global config must be a
real writable file, never /dev/null: ensure_beads_role runs `git config
--global beads.role maintainer` and cannot lock /dev/null. Tests that
WRITE global config still call testutil.IsolatedGitConfig for a per-test
file so writes don't leak through the shared one, and helpers that build
an explicit env -i subprocess environment still append
SharedIsolatedGitConfigEnv.
…#92)

Gate the fork's zookanalytics/beads pseudo-version replace past the
check-gomod-replace guard so Preflight/static-checks runs to completion
and fork PRs can auto-land again (was FAILURE-at-guard on main).

- gc-jwho8: allowlist the beads fork entry in scripts/check-gomod-replace.sh
- gc-434qa (pre-open signoff): gate the allowlist on pseudo-version shape so
  the exception stays narrow, plus scripts/gomod_replace_guard_test.go coverage

The FORK_REPLACE_ALLOWLIST entry is a TEMPORARY bridge: delete it when the
beads fork converges upstream and go.mod's `replace` returns to a released
semver tag.

Closes gc-bvjbs.
These non-conflicted cmd/gc test files kept pre-rebase call shapes and only
surfaced post-rebase (cmd/gc could not build mid-rebase until the
resolveBdScopeTarget caller fix landed):
- startControllerSocket gained demandDirty (gc-qedgc #69) — add missing nil arg
- startCandidate's raw bead pointer became info session.Info (WI-6 R4):
  session:&bead -> info: SeedBead / InfoFromMeta
- sortCandidatesByWakeFairness gained a cfg param
Rebase of origin/main onto upstream/main (adc03f1) grew the tracked-source AST counts (fork tests atop new upstream). Ratchet bootstrapPolicy + test-resources.toml baselines to the current census and regenerate the TESTING.md ledger block. Supersedes the pre-rebase census snapshot 7bba3de, which drops as empty against new upstream (the census is a pure function of the tree, plan §5e).
…ut arg (gc-u1g6k)

Upstream adc03f1 added a checkTimeout time.Duration parameter to doDoctor (between the bool flags and the writers). One fork test call site was missed by the existing test-alignment commit; pass 0 to match every other call site.
…gc-qin3c)

The fork core-path resolver landed via #85 (gc-os8fn) but trailed the reviewed
upstream PR gastownhall#4527 (gc-z0vi2): the 1M marker list was missing
claude-sonnet-5, so a bare "claude-sonnet-5" — a 1M-context model — resolved to
the 200K default on the API/session-log path and the injector alike. That is the
same under-report class #85 fixed for the bare opus-4-6/4-7/4-8 and sonnet-4-6
families, left open for the newer model.

Bring the five fork-relevant files to match the reviewed PR commit (5a9daff):
  - add claude-sonnet-5 to the 1M markers
  - fold the familyWindows map + separate familyOrder slice into one ordered
    struct slice (longest-match-first inline); no behavior change for existing
    families
  - expand tests: sonnet-5 cases on both resolvers, and a table-driven injector
    test across the shared model table (opus-4-8 / sonnet-5 / gpt-5)

Excludes the PR's upstream-CI-only files (.github/workflows/ci.yml,
scripts/cipolicy/policy.go) — the fork carries its own CI shape and cipolicy
execution digest, which must not be overwritten with upstream's.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants