Skip to content

Commit 891e892

Browse files
committed
merge: bring in main and reconcile the classifier with the #1145 permanence gate
main extracted classifier-hint building into internal/diagnostics/hints, which already covers the Docker enrichment this branch was adding inline — so the conflict resolves to main's hints.For call, with DockerArgs added there because the #1143 git-dependency remediation reads it. #1155's TestParkableCode_ChildStderrNeverProvesPermanence pinned the OLD classifications to isolate its permanence gate; this branch fixes those classifications, so the expected codes move. The gate's invariant is unchanged and still asserted: two stderr-only rows that still reach a PERMANENT code are added so it is never left untested.
2 parents d5b21d4 + e8d2ba3 commit 891e892

52 files changed

Lines changed: 7314 additions & 168 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/unit-tests.yml‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,35 @@ jobs:
120120
New-Item -ItemType Directory -Force -Path web/frontend
121121
Copy-Item -Recurse frontend/dist web/frontend/
122122
123+
# Warm the tiktoken vocabulary ONCE, before the parallel test run.
124+
#
125+
# tiktoken-go downloads the BPE on first use into a shared temp dir and
126+
# finishes with an atomic rename. `go test ./...` runs packages in
127+
# parallel, so several test binaries race to download the same file, and
128+
# on Windows the loser hits "Access is denied" on the rename and the
129+
# package fails — observed as TestBaseline_CountToolWithSchemaParity
130+
# flaking in bench/arms with no code change anywhere near it.
131+
#
132+
# Setting TIKTOKEN_CACHE_DIR alone does NOT fix this: it only names a
133+
# cache, and an empty one still races. Populating it first does, because
134+
# every later tokenizer construction is a cache hit with no rename.
135+
- name: Warm the tiktoken vocabulary cache
136+
run: go run ./bench/cmd/warmtiktoken
137+
env:
138+
TIKTOKEN_CACHE_DIR: ${{ runner.temp }}/tiktoken
139+
123140
- name: Run unit tests (Windows)
124141
if: matrix.os == 'windows-latest'
125142
shell: pwsh
126143
run: go test -v -race -timeout 10m '-coverprofile=coverage.out' -covermode=atomic '-skip=E2E|Binary|MCPProtocol|TestInfoEndpoint|TestGracefulShutdownNoPanic|TestSocketInfoEndpoint' ./...
144+
env:
145+
TIKTOKEN_CACHE_DIR: ${{ runner.temp }}/tiktoken
127146

128147
- name: Run unit tests (Unix)
129148
if: matrix.os != 'windows-latest'
130149
run: go test -v -race -coverprofile=coverage.out -skip "E2E|Binary|MCPProtocol|TestInfoEndpoint|TestGracefulShutdownNoPanic|TestSocketInfoEndpoint" ./...
150+
env:
151+
TIKTOKEN_CACHE_DIR: ${{ runner.temp }}/tiktoken
131152

132153
- name: Generate coverage report (Windows)
133154
if: matrix.os == 'windows-latest'

‎.pre-commit-config.yaml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ repos:
77
rev: v5.0.0
88
hooks:
99
- id: trailing-whitespace
10+
# A unified diff encodes meaning in leading whitespace: an unchanged
11+
# context line begins with a single space, and a blank context line IS
12+
# that lone space. Stripping it turns valid patches into ones git apply
13+
# rejects — observed on bench/mcpmark/mcpproxy_arm.patch, where the hook
14+
# silently rewrote 4 context lines.
15+
exclude: '\.(patch|diff)$'
1016
- id: end-of-file-fixer
1117
- id: check-merge-conflict
1218

‎ROADMAP.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ graph LR
772772
| Web UI + macOS app UX audit | In progress | P0 | — | | |
773773
| Release qualification gate (auto-QA matrix blocks the tag) | In progress | P0 | — | [081-release-qa-gate](./specs/081-release-qa-gate/) | |
774774
| Action log / transparency — info at a glance | In progress | P1 | — | | |
775-
| Token-efficiency benchmark: measured savings, published results | In progress | P1 | 37/64 (58%) | [103-token-bench](./specs/103-token-bench/) | #1141 |
775+
| Token-efficiency benchmark: measured savings, published results | In progress | P1 | 62/64 (97%) | [103-token-bench](./specs/103-token-bench/) | #1141 |
776776
| Telemetry identity & data quality (machine_id + CI-filter hardening) | In progress | P1 | — | | |
777777
| Telemetry v7: honest funnel + churn instrumentation | In progress | P1 | — | [080-telemetry-v7-churn](./specs/080-telemetry-v7-churn/) | |
778778
| Planning/docs truth automation | In progress | P2 | — | | |
@@ -914,4 +914,4 @@ Legend: `shipped` ≥95% checked · `in-flight` 1–94% · `drafted` 0% · `—`
914914
| [100-prompt-rugpull-baseline](./specs/100-prompt-rugpull-baseline/) | — | — |
915915
| [101-tpa-db](./specs/101-tpa-db/) | — | — |
916916
| [102-schema-deferred](./specs/102-schema-deferred/) | `shipped` | 89/89 (100%) |
917-
| [103-token-bench](./specs/103-token-bench/) | `in-flight` | 37/64 (58%) |
917+
| [103-token-bench](./specs/103-token-bench/) | `shipped` | 62/64 (97%) |

‎bench/README.md‎

Lines changed: 111 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,12 +465,108 @@ offline reproduction needs the cache pre-populated — warm it once with network
465465
access, or restore a known-good copy (which is what `.github/workflows/bench.yml`
466466
does via its `actions/cache` step).
467467

468+
### Reproducing a published figure (SC-004)
469+
470+
Someone with no prior context reproduces the deterministic figures **exactly**,
471+
and the model-dependent ones within the stated numeric tolerance (FR-022 — see
472+
the tokenizer caveat under "Known limitations"), by following these steps and
473+
nothing else.
474+
475+
**1. Populate the tokenizer cache. Naming it is not filling it.**
476+
477+
```bash
478+
export TIKTOKEN_CACHE_DIR="$HOME/.cache/tiktoken"
479+
go run ./bench/cmd/bench \
480+
-corpus-v2 specs/083-discovery-profiler/datasets/corpus_v2.tools.json \
481+
-out /tmp/warm # downloads the vocabulary once — needs network
482+
ls "$TIKTOKEN_CACHE_DIR" # non-empty ⇒ every later run is genuinely offline
483+
```
484+
485+
`TIKTOKEN_CACHE_DIR` only *names* a directory. A first run with the variable set
486+
and the directory empty still reaches the network, so a machine "configured for
487+
offline" but never warmed fails at the first token count rather than at
488+
configuration time — and it fails the same way on an air-gapped reviewer's
489+
laptop as it does in a network-restricted CI job. Warm it once with network
490+
access, or restore a known-good copy (which is what `.github/workflows/bench.yml`
491+
does via its `actions/cache` step).
492+
493+
**2. Supply a fleet input. There is no default, and there is no fallback.**
494+
495+
A menu cost is a property of the tool definitions the agent was shown. A
496+
recording carries the *call shape* — sequence, tool mix, call counts — and no
497+
fleet snapshot whatsoever, so a recording-only invocation has nothing to price:
498+
499+
```bash
500+
go run ./bench/cmd/bench -replay ~/replay-corpus.jsonl -out bench/results
501+
# bench: replay requires a fleet input as well as a recording: a menu is a
502+
# property of the tool definitions and the activity export carries no fleet
503+
# snapshot, so a recording on its own computes nothing — pass a frozen corpus
504+
# or a live-proxy catalog (this is an error, not a degraded run)
505+
# exit status 1
506+
```
507+
508+
That is a **hard error, not a degraded run**. The alternative — quietly scoring
509+
against an empty or assumed fleet — would produce a plausible-looking number
510+
with no fleet shape behind it, which is exactly the failure every percentage in
511+
this report carries a `fleet_shape` to prevent. Pass the frozen corpus for a
512+
reproducible figure, or a live `-proxy` for today's fleet.
513+
514+
**3. Run the pinned command, twice.** The deterministic half is byte-identical
515+
across runs once the wall-clock stamp is removed — the `diff` recipe under
516+
"Verify determinism" above is the check, and it is what SC-002 means. If two
517+
runs on the same machine differ by anything other than `generated_at`, stop:
518+
nothing downstream is worth comparing yet.
519+
520+
**4. Read the three honesty marks before quoting anything.** They are fields in
521+
`report.json`, not prose in this file, because a report travels without its
522+
README:
523+
524+
| Field | Says | If it is missing |
525+
|-------|------|------------------|
526+
| `run_status.completeness` | `complete`, or `partial` with a reason and the unmeasured cells named | Undeclared completeness — the run is **not publishable** as a complete comparison (FR-032) |
527+
| `<block>.inputs.independently_reproducible` | whether an outsider can obtain the inputs at all | Undeclared availability — treated as **not** reproducible, and blocks publication (FR-030) |
528+
| `<block>.records` | where this block's raw per-run records sit, as a path relative to the run directory | No `records` key at all blocks publication; `retention: not_retained` does not — the figure is real, just no longer traceable to its inputs (FR-029) |
529+
530+
`bench.ReportV2.PublicationCheck()` applies all three and returns blockers plus
531+
caveats. A partial run blocks. An undeclared input blocks. A report in which
532+
*every* block rests on a private recording blocks — see step 5.
533+
534+
**5. Know what you cannot reproduce.** A replay run over someone's own exported
535+
activity is scored from **private recorded sessions**: the recording is raw user
536+
traffic, it is never published (FR-006), and no procedure exists that would hand
537+
it to you. Such a block is marked `independently_reproducible: false` with the
538+
limitation stated in the document, and it may **never be the sole support for a
539+
published claim** — a report whose only figures come from one operator's
540+
recording is a claim nobody outside can check, however honestly each row is
541+
labelled. Publish it beside a block an outsider *can* reproduce (the committed
542+
corpora, or a pinned public task suite), and keep the caveat attached.
543+
544+
**6. Raw records are run-local and not durable.** They are written under the
545+
gitignored `bench/results/` tree — the same tree SC-011 forbids committing and
546+
the same tree a cleanup empties. The report references them by a path relative
547+
to its own directory, never an absolute one: an absolute path would carry the
548+
operator's filesystem into a published document and would dangle on every other
549+
machine. Copy the run directory elsewhere before relying on those records; once
550+
they are gone the reference degrades to `records not retained` rather than
551+
pointing at nothing.
552+
553+
Each mark is written by the run that produces the block: the replay entry point
554+
sets `replay.inputs` (`private-recording` for an operator's own export) and
555+
`replay.records`; the agent loop sets its own pair plus the report-level
556+
`run_status`, derived from the cells it planned against the cells it actually
557+
measured. `WriteJSON` re-checks every records reference against the directory it
558+
is writing into, so a reference cannot be published pointing at a file that is
559+
already gone.
560+
468561
### Before publishing a replay or agent-loop number
469562

470563
1. Recompute the achievable ceiling **for each fleet shape**; never carry a
471564
previous fleet's ceiling forward.
472565
2. Quote the fleet shape beside every percentage.
473-
3. Confirm no report is tracked:
566+
3. Confirm the run is not `partial`, and that no private-recording figure is
567+
standing alone — `PublicationCheck()` answers both, and returns the caveats
568+
that must travel with the number even when it publishes.
569+
4. Confirm no report is tracked:
474570
```bash
475571
test -z "$(git ls-files bench/results)" && echo "clean (SC-011)"
476572
```
@@ -588,3 +684,17 @@ headline numbers (image drift can change the tool corpus).
588684

589685
Methodology questions / disputes: open an issue in `smart-mcp-proxy/mcpproxy-go`
590686
and tag the maintainers, or comment on the roadmap benchmark ticket (MCP-42).
687+
688+
Warm it with the one-line command rather than by hand — the same step CI runs
689+
before its parallel test sweep:
690+
691+
```bash
692+
export TIKTOKEN_CACHE_DIR="$HOME/.cache/tiktoken"
693+
go run ./bench/cmd/warmtiktoken
694+
```
695+
696+
Why a dedicated step: `go test ./...` runs packages in parallel, and several
697+
test binaries race to download the same vocabulary into one cache dir. On
698+
Windows the loser fails its whole package on the atomic rename — it surfaced as
699+
`bench/arms` flaking with no code change near it. Naming the cache does not fix
700+
that; populating it first does.

0 commit comments

Comments
 (0)