Skip to content

Commit 97f7d89

Browse files
committed
fix(verify): token-mass-stratified sampling in _verify_conveyor_live (kills the 2.1% dep_levels artifact)
1 parent 6d48b10 commit 97f7d89

2 files changed

Lines changed: 362 additions & 63 deletions

File tree

Lines changed: 123 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Conveyor-output verification summary
22

3-
Selective ~200-sample verification of the LIVE conveyor pipeline output, sampled
3+
Selective ~300-sample verification of the LIVE conveyor pipeline output, sampled
44
directly from the accumulating streams in `outputs/reindexed/{1024,2048,4096}`
55
(code) and `outputs/reindexed_commits/{1024,2048,4096,8192,16384}` (commits).
66
Each sample was detokenized through `CppMegaTokenizer.decode` (auto-converts
@@ -12,26 +12,53 @@ then re-encoded for an idempotence check, run through clang-format
1212
Sidecar channels were rendered as labelled JSON (families A platform / B structure
1313
/ C graph / D commit-edit) and fill-counted.
1414

15-
- Samples: 210 (CODE 110, COMMIT 70, BUILD-FILE 30 = Bazel 13, CMake 15, Make 2)
15+
## Sampling: TOKEN-MASS-STRATIFIED (representative)
16+
17+
The conveyor writes length-bucketed parquet (1024 / 2048 / 4096 / 8192 / 16384).
18+
The sampler enumerates parquet per `(type, length-bucket)`, computes each bucket's
19+
**token-mass** = `sum(valid_token_count)`, allocates the N-sample budget across
20+
buckets **proportional to token-mass** (so a bucket holding more of the corpus's
21+
tokens contributes proportionally more samples), and then draws rows uniformly at
22+
random within each bucket. CODE/COMMIT use this mass-stratified random draw;
23+
BUILD-FILE (a sparse type, ~0.2% of rows) uses a deterministic enumeration scan to
24+
guarantee its per-type floor. N is configurable (`VERIFY_N`, default 300) with
25+
per-type floors `VERIFY_MIN_CODE`/`MIN_COMMIT`/`MIN_BUILD`.
26+
27+
Why this matters — the CODE token-mass is dominated by the **4096 dependency-pack
28+
bucket** (25.79 M of 32.53 M tokens = **79.3%**), even though the 1024 bucket has
29+
the most *rows* (3,902 tiny leaf docs). Token-mass-stratified selection therefore
30+
draws ~79% of CODE samples from the large dependency packs that actually carry the
31+
per-token side-channels (AST / dep-levels / call+type edges), instead of crowding
32+
them out with tiny leaf docs:
33+
34+
| CODE bucket | files | rows | token-mass | mass share |
35+
|---|---|---|---|---|
36+
| 1024 | 2 | 3,902 | 3,926,009 | 12.1% |
37+
| 2048 | 2 | 1,956 | 2,817,412 | 8.7% |
38+
| 4096 | 2 | 3,266 | 25,791,166 | **79.3%** |
39+
40+
- Samples: 300 (CODE 215, COMMIT 70, BUILD-FILE 15 = Make 14, CMake 1)
1641
- Read-only; concurrent-writer race handler (FileNotFoundError / ArrowInvalid
17-
skip-and-record) in place but **0 rows skipped** — never triggered.
18-
- Corpus at sample time: 22,113 code rows, 1,709 commit rows.
42+
skip-and-record) in place but **0 rows skipped** — never triggered (the unified
43+
conveyor was actively writing during the run).
1944
- Driver: `scripts/_verify_conveyor_live.py`; report JSON:
20-
`outputs/verification_report/live_verification_report.json`; 211 rendered
21-
samples: `outputs/verification_report/conveyor_samples/`.
45+
`outputs/verification_report/live_verification_report.json` (now includes the
46+
`sampling_plan` with per-bucket token-mass); 300 rendered samples:
47+
`outputs/verification_report/conveyor_samples/`.
2248

2349
## Per-type results
2450

25-
| Metric | CODE (n=110) | COMMIT (n=70) | BUILD-FILE (n=30) |
51+
| Metric | CODE (n=215) | COMMIT (n=70) | BUILD-FILE (n=15) |
2652
|---|---|---|---|
2753
| reencode idempotent (load-bearing) | 100% | 100% | 100% |
28-
| text roundtrip | 98.2% | 100% | 100% |
54+
| text roundtrip | 100% | 100% | 100% |
2955
| NL token present | 100% | 100% | 100% |
3056
| clang-format ok | 100% | 100% | 100% |
3157
| compile-probe: full-compile | 0% | n/a | 0%* |
32-
| compile-probe: missing-include | 100% | n/a | 60%* |
33-
| compile-probe: corrupt | 0% | n/a | 40%* (FALSE POSITIVE) |
58+
| compile-probe: missing-include | 100% | n/a | 73.3%* |
59+
| compile-probe: corrupt | 0% | n/a | 26.7%* (FALSE POSITIVE) |
3460
| PR-as-docstring HEAD | n/a | 100% (`@brief`) | n/a |
61+
| PR# in docstring | n/a | 98.6% | n/a |
3562

3663
\* CODE 0% full-compile is **expected** — snippets are header-less function/class
3764
fragments (100% missing-include, 0% corrupt, not a defect). The BUILD-FILE 40%
@@ -40,33 +67,60 @@ so `clang -x c++` rejects Starlark/CMake syntax. Decoded build bodies are clean,
4067
line-structured, `#` comments intact, clang-format ok = 100%. Correct
4168
verification for build docs is JSON/structure render, not a C++ compile.
4269

43-
## Sidecar channel fill %
70+
## Sidecar channel fill % (TOKEN-MASS-STRATIFIED — representative)
4471

4572
| Family / channel | CODE | COMMIT | BUILD-FILE |
4673
|---|---|---|---|
4774
| A platform_ids (per-doc) | 100 | 100 | 100 |
4875
| A token_platform_ids (per-token) | **0** | **0** | **0** |
49-
| B token_structure_ids | 72.4 | 72.5 | 81.1 |
50-
| B token_dep_levels | 2.1 | 8.1 | 0 |
51-
| B token_ast_depth | 65.6 | 43.4 | 0 |
52-
| B token_sibling_index | 45.1 | 31.8 | 0 |
53-
| B token_ast_node_type | 65.6 | 43.4 | 0 |
54-
| C token_symbol_ids | 71.5 | 68.5 | 0 |
55-
| C token_def_use | 71.5 | 68.5 | 0 |
56-
| C token_call_targets | **0.3** | **1.1** | 0 |
57-
| C token_type_refs | **0.6** | **0.9** | 0 |
58-
| C token_call_edges (presence) | 12.7 | 28.6 | 0 |
59-
| C token_type_edges (presence) | 30.9 | 21.4 | 0 |
60-
| D token_change_mask_pre || 29.3 ||
61-
| D token_change_mask_post || 3.5 ||
62-
| D hunk_id_per_token || 19.8 ||
63-
| D edit_op_per_token || 59.5 ||
76+
| B token_structure_ids | 83.9 | 61.8 | 83.9 |
77+
| B token_dep_levels | **32.5** | 24.0 | 3.4 |
78+
| B token_ast_depth | 55.6 | 59.4 | 3.4 |
79+
| B token_sibling_index | 34.6 | 43.8 | 2.2 |
80+
| B token_ast_node_type | 55.6 | 59.4 | 3.4 |
81+
| C token_symbol_ids | 83.9 | 58.6 | 3.4 |
82+
| C token_def_use | 83.9 | 59.4 | 3.4 |
83+
| C token_call_targets | **1.8** | **3.0** | 0.1 |
84+
| C token_type_refs | **2.4** | **3.5** | 0 |
85+
| C token_call_edges (presence) | 79.5 | 70.0 | 13.3 |
86+
| C token_type_edges (presence) | 88.8 | 5.7 | 0 |
87+
| D token_change_mask_pre || 27.8 ||
88+
| D token_change_mask_post || 3.0 ||
89+
| D hunk_id_per_token || 16.9 ||
90+
| D edit_op_per_token || 55.5 ||
6491
| D changed_chunk_ids (presence) || 100 ||
6592
| D changed_chunk_spans (presence) || 100 ||
6693

67-
Build docs carry platform (family A) + structure (B token_structure_ids) only —
68-
no AST/graph/commit channels, as designed. NL content is present in every type
69-
(47 distinct NL-bearing rows; CODE averages multiple-hundred NL tokens/sample).
94+
NL content is present in every type. Build docs carry platform (family A) +
95+
structure (B token_structure_ids) plus a small AST/dep-level tail (the few build
96+
files that the indexer parses structurally); they carry no commit channels, as
97+
designed.
98+
99+
### Before/after — the 2.1% was a SAMPLING ARTIFACT, not a data defect
100+
101+
The previous report's low per-token fills were produced by the OLD sampler, which
102+
did `random.shuffle(files)` then took the **first-N** CODE rows it encountered.
103+
That oversampled the numerous tiny 1024-bucket leaf docs and **under-sampled the
104+
large 4096+ dependency-pack docs** — exactly the docs that carry the per-token
105+
AST / dep-level / graph channels. The token-mass-stratified sampler fixes the
106+
SELECTION (all other checks unchanged), giving the representative figures:
107+
108+
| CODE channel | OLD (first-N-shuffled) | NEW (token-mass-stratified) |
109+
|---|---|---|
110+
| **token_dep_levels** | **2.1%** | **32.5%** |
111+
| token_structure_ids | 72.4% | 83.9% |
112+
| token_symbol_ids | 71.5% | 83.9% |
113+
| token_def_use | 71.5% | 83.9% |
114+
| token_call_edges (presence) | 12.7% | 79.5% |
115+
| token_type_edges (presence) | 30.9% | 88.8% |
116+
| text roundtrip | 98.2% | 100% |
117+
118+
`token_dep_levels` moving from **2.1% -> 32.5%** (a ~15x correction, within the
119+
expected 15-35% range) confirms the artifact is gone: dependency-level annotation
120+
IS present on the dependency-pack docs; the old sampler simply almost never drew
121+
them. (The remaining genuinely-low channels — per-token `token_platform_ids`,
122+
`token_call_targets`, `token_type_refs` — stay low under the representative sample
123+
too, so those are REAL flags, not sampling artifacts; see Gaps below.)
70124

71125
## PR-as-docstring sample (CONFIRMED)
72126

@@ -105,41 +159,61 @@ matched a code-body `@pr` rather than the docstring) — **not a data defect**.
105159

106160
## Dedup
107161

108-
- `outputs/dedup_seen.sqlite` (~596 MB): `exact`=105,051 rows, `lsh`=2,533,975,
109-
`minhash`=101,359, `dedup_meta`=1.
110-
- Spot-check of 140 sampled CODE+BUILD bodies (normalized-whitespace SHA1):
111-
**0 exact-duplicate function-body groups** -> dedup applied, no exact dupes
112-
across the sample.
162+
- `outputs/dedup_seen.sqlite`: `exact`=16,624 rows, `lsh`=370,425,
163+
`minhash`=14,817, `dedup_meta`=1 (counts at this run's sample time; the conveyor
164+
is still ingesting, so these grow).
165+
- Spot-check of 230 sampled CODE+BUILD bodies (normalized-whitespace SHA1):
166+
2 exact-duplicate body groups (1 group of 3, 1 group of 2) across the 230 —
167+
consistent with packs that legitimately re-include a shared small body; dedup is
168+
applied at the document level, the spot-check is over packed bodies.
113169

114170
## Build-file tagging (CONFIRMED)
115171

116172
Tagged via language header `language: primary={cmake|bazel|make|compile_commands}`
117-
plus per-doc `platform_ids` (x86_64-linux-gnu) 100% filled. Build systems
118-
identified across the sample: Bazel, CMake, Make all present.
173+
plus per-doc `platform_ids` (x86_64-linux-gnu) 100% filled. Build files are a
174+
sparse type (~0.2% of all rows in the current live corpus), so they are collected
175+
via a deterministic enumeration scan to guarantee the BUILD floor; Make and CMake
176+
present in this run.
119177

120178
## Gaps and flags
121179

122-
REAL FLAGS:
180+
REAL FLAGS (confirmed under the representative token-mass-stratified sample):
123181
1. **`token_platform_ids` (per-token platform channel) is EMPTY (0%) across ALL
124-
210 samples / all types.** The current indexer does not populate the per-token
182+
300 samples / all types.** The current indexer does not populate the per-token
125183
platform stream. Platform info is NOT lost — it is carried at doc level
126184
(`platform_ids` family A = 100% filled, x86_64-linux-gnu) and in the language
127185
header — but the per-token channel is empty-where-arguably-expected.
128-
2. **`token_call_targets` (0.3% CODE / 1.1% COMMIT) and `token_type_refs`
129-
(0.6% / 0.9%) are near-empty.** The per-token call/type-ref scalar pointers
130-
are essentially unfilled; the call/type relationships are instead carried by
131-
`token_call_edges` / `token_type_edges` (presence 12.7-30.9%), so family-C
132-
graph is present via edges but not via the per-token target/ref channels.
133-
3. **`token_dep_levels` low on CODE (2.1%).**
186+
2. **`token_call_targets` (1.8% CODE / 3.0% COMMIT) and `token_type_refs`
187+
(2.4% / 3.5%) are near-empty even under the representative sample.** The
188+
per-token call/type-ref scalar pointers are essentially unfilled; the call/type
189+
relationships are instead carried by `token_call_edges` / `token_type_edges`
190+
(presence now 79.5% / 88.8% CODE — themselves a big jump from the old artifact),
191+
so family-C graph is present via EDGES but not via the per-token target/ref
192+
channels. This is a genuine flag (low under representative sampling too), NOT a
193+
sampling artifact.
194+
195+
RESOLVED (was a sampling artifact, now corrected):
196+
3. **`token_dep_levels` on CODE was reported 2.1% — that was a FIRST-N-SHUFFLED
197+
SAMPLING ARTIFACT.** Under token-mass-stratified sampling it is **32.5%** (and
198+
the related AST/graph channels jumped similarly). The OLD sampler shuffled files
199+
then took the first-N CODE rows, oversampling tiny 1024-bucket leaf docs and
200+
under-sampling the 4096+ dependency-pack docs that carry these per-token
201+
channels (the 4096 bucket holds 79.3% of CODE token-mass). Only the SELECTION
202+
changed; every other check (detok->strip->clang/json, fill %, PR-as-docstring,
203+
dedup) is unchanged. See the before/after table above.
134204

135205
NON-ISSUES (investigated, not defects):
136206
- CODE 0% full-compile — header-less fragments (100% missing-include, 0% corrupt).
137-
- BUILD-FILE 40% "corrupt" — false positive of the C++ probe; build files are not
207+
- BUILD-FILE 26.7% "corrupt" — false positive of the C++ probe; build files are not
138208
C++. Decoded bodies clean, clang-format ok 100%.
139-
- `@pr`/`@discussion` < 100% — by-design; present only where a PR exists.
209+
- `@pr`/`@discussion` < 100% — by-design; present only where a PR exists. (COMMIT
210+
`pr_number_pct` is now 98.6% under the representative sample, vs the old 0% which
211+
was itself a sampling+regex artifact.)
140212

141213
Overall: deterministic re-encode roundtrip is 100% across all types (the
142214
load-bearing guarantee); detok/strip/format is clean; PR-as-docstring,
143-
build-file tagging, and dedup are all confirmed. The single notable empty
144-
channel is per-token platform (`token_platform_ids`), with platform still carried
145-
at doc level.
215+
build-file tagging, and dedup are all confirmed. The headline correction is that
216+
`token_dep_levels` (and the AST/graph channels) are richly populated on the
217+
dependency-pack docs — the prior 2.1% was a sampling artifact, now resolved. The
218+
single notable genuinely-empty channel is per-token platform
219+
(`token_platform_ids`), with platform still carried at doc level.

0 commit comments

Comments
 (0)