Skip to content

feat(synthetic): generate distribution-faithful workloads from measured profiles - #5670

Merged
Sinity merged 23 commits into
masterfrom
claude/generator
Sep 29, 2026
Merged

Sinity merged 23 commits into
masterfrom
claude/generator

Conversation

@Sinity

@Sinity Sinity commented Sep 27, 2026 •

Copy link
Copy Markdown
Owner

Summary

Adds a seeded workload generator for Claude Code and Codex (about 99% of source bytes), driven by committed aggregate-only profiles measured from real sources. It is meant for fixtures and benchmarks that need realistic volume and structure. Also fixes the ChatGPT synthetic witness schema violation (polylogue-16gjl).

Problem (evidence)

A fidelity audit compared real sources, parsed with production parse_payload, against SyntheticCorpus output (aggregate numbers only):

  • Claude Code: median session 340 KB real vs 3.7 KB synthetic; records per session p99 1,562 vs 14; user role share 2% vs 24%; tool call/result pairing 1.00 vs 0.00; usage coverage 62% vs 0%.
  • Codex: synthetic used the legacy flat form with no envelopes, no tool pairing and no subagent lineage (about 50% of real rollouts are subagents).
  • Every committed schema package has workload_profile_file: null (the incremental inference path never writes one), so the generator's session-level profile code is inert.
  • Speed was about 0.09 MB/s.

Solution

  • polylogue/schemas/synthetic/workload.py: generate_workload_corpus(seed=..., target_bytes|target_sessions=..., origins=...) → iter_files() (in memory, one session at a time) or write(root) (the claude-code/projects and codex/sessions trees, including subagent transcripts, .meta.json and tool-result sidecars).
    • Relational records (messages, tool calls and results, usage, session meta, turn context) are rendered with real ids, parent chains and call ids.
    • Every other record kind is instantiated from its measured key skeleton.
    • No size caps: tails are sampled from log2 histograms.
  • polylogue/schemas/providers/{claude-code,codex}/workload-corpus.json, measured with the new devtools schema workload-profile, contain:
    • record-kind transition counts, log2 histograms of record counts, per-kind text lengths and gaps;
    • subagent fan-out and orphan subagents;
    • per-kind non-ASCII, tool-error and sidecar shares;
    • key skeletons.
    • Privacy: identifier keys only; data-keyed containers (JSON-schema properties, model-usage maps, tracked file paths, structured output) stay opaque; a kind or skeleton is published only if seen in ≥3 files; counts are rounded to 2 significant figures.
  • build_records.py: ChatGPT timestamp defaults apply only where the element declares a numeric field.

Result on 300-session samples:

Claude Code real generated Codex real generated
roles assistant/tool/user .62/.36/.016 .63/.35/.019 .66/.32/.013 .66/.32/.010
tool pairing 1.00 0.97 0.88 0.95
text length p50/p90/p99 253/2.5K/19.7K 270/2.7K/18.5K 12/3.0K/41K 11/2.8K/33K

Generation runs at about 18 MB/s. Parser line coverage under generated data is 75% (Claude Code) and 56% (Codex) of the lines real sources reach.

Verification

  • devtools test tests/unit/core/test_synthetic_workload.py tests/unit/devtools/test_schema_workload_profile.py tests/unit/core/test_synthetic_wire_support.py: result in the thread below.
  • devtools schema closure: all changed production files OUT.
  • ruff format/check on changed files: clean.

Residuals

  • Content semantics inside strings are out of reach: Codex code-mode JS, per-tool toolUseResult shapes, apply_patch bodies. So are claude-ai/ChatGPT/Gemini CLI renderers and the inert profile code in the schema generator. All are tracked in polylogue-958ee, together with the old generator's arbitrary caps.
  • Legacy pre-envelope Codex rollouts are excluded from the profile; a rollout never mixes formats.

Self-review

I reviewed the complete diff at the final head, including the regenerated profiles.

The profile publishes aggregates only: log2 histograms, shares, template skeletons of field names and kind tokens, and measured numeric leaves. The profile test fails if any source text, id or path is copied. I grepped the regenerated workload-corpus.json files for path- and identity-shaped strings and found none.

Profiling is faithful to what the parsers read

  • Every tool_result block of a message is measured: length, error outcome, and sidecar or large-inline evidence.
  • Companion thinking and text blocks are counted by multiplicity. A defect I introduced in this round, where the companion tally reused the session's record counter, was found in review and fixed; the profiles were regenerated after the fix.
  • Exec envelopes are recognized as the parser recognizes them and are counted per called tool.
  • List skeletons keep every distinct item shape, and float leaves are measured.
  • A malformed record refuses the profile (MalformedSourceError); only blank lines are skipped.

Generation reproduces the measured shapes

  • Each generated field's whole measured size is its sampled length, including envelope and escaping. The fit is exact under escaping, and a target below the envelope yields the envelope alone.
  • A result message keeps its sampled block count, and blocks beyond the open calls get fresh unmatched ids.
  • An envelope-bearing result (Edit, Write, Agent, Task) answers its call alone.
  • A spawned agent's meta.json names its spawning call.

Verification:

  • devtools test tests/unit/core/test_synthetic_workload.py tests/unit/devtools/test_schema_workload_profile.py on the final head 17932da: 89 passed, 0 failed.
  • agentctl job start polylogue verify_quick: succeeded (job 2137).

Residuals: the kind-mix fidelity test materializes a full corpus and is marked with a 300 s timeout. It is slow by construction, and its tolerance is unchanged.

🤖 Generated with Claude Code

https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-29T01:05:49.231716Z c41b8b6 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4515185c22

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread devtools/schema_workload_profile.py Resolved
Comment thread devtools/schema_workload_profile.py Resolved
Comment thread polylogue/schemas/synthetic/workload.py Resolved
Comment thread polylogue/schemas/synthetic/workload.py Resolved
Comment thread polylogue/schemas/synthetic/workload.py Resolved
Comment thread polylogue/schemas/synthetic/workload.py Resolved
Comment thread polylogue/schemas/synthetic/workload.py Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d7cd9bc67d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread devtools/schema_workload_profile.py Resolved
Comment thread polylogue/schemas/synthetic/workload.py Resolved
Comment thread polylogue/schemas/synthetic/workload.py Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e8b44f89b0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread devtools/schema_workload_profile.py Resolved
Comment thread polylogue/schemas/synthetic/workload.py Resolved
Comment thread polylogue/schemas/synthetic/workload.py Resolved
Comment thread polylogue/schemas/synthetic/workload.py Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 995f11630a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread polylogue/schemas/synthetic/workload.py Resolved
Comment thread devtools/schema_workload_profile.py Resolved
Comment thread polylogue/schemas/synthetic/workload.py Resolved
Comment thread polylogue/schemas/synthetic/workload.py Resolved
Comment thread polylogue/schemas/synthetic/workload.py Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 99b2d52949

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread polylogue/schemas/synthetic/workload.py Resolved
Comment thread polylogue/schemas/synthetic/workload.py Resolved
Comment thread devtools/schema_workload_profile.py Resolved
Comment thread polylogue/schemas/synthetic/workload.py Resolved
Comment thread polylogue/schemas/synthetic/workload.py Resolved
Comment thread polylogue/schemas/synthetic/workload.py Resolved
Comment thread polylogue/schemas/synthetic/workload.py Resolved
Comment thread polylogue/schemas/synthetic/workload.py Resolved
Sinity and others added 7 commits September 28, 2026 09:21
…hema

The tree generator defaulted create_time/update_time to epoch floats on
every ChatGPT element, including the export asset index whose schema types
those fields without a number, so its witnesses failed schema validation.
Defaults now apply only where the selected element declares a numeric field.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4
…ed profiles

The schema-driven generator proves shape, not workload: its sessions were
~100x smaller than real ones, tool results never paired with calls, Codex
used the legacy flat form, and no committed package carries a workload
profile, so its session-level controls were inert.

Add a workload generator for Claude Code and Codex driven by committed,
aggregate-only profiles (record-kind Markov chains, log2 histograms of
record counts, text lengths and gaps, subagent fan-out, per-kind shares and
key skeletons of non-relational records), measured by the new
`devtools schema workload-profile`. Generation is seeded, streams one
session at a time, keeps every tail, and writes the source trees the daemon
watches, including subagent transcripts and tool-result sidecars.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4
Real sources hold metadata-only transcripts that the parser refuses, and
the generator reproduces them; the parse-through test now requires
admission exactly for streams carrying conversational records.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4
- Classify multi-block assistant records by their tool call, and measure
  the matching block, so [thinking, tool_use] records keep their calls.
- Publish only field names already in the committed schema package in
  record skeletons.
- Count written bytes after sidecar references are resolved.
- Emit Codex tool outputs in the producer's structural forms (unified-exec
  envelope, JSON metadata.exit_code) at their measured shares, so parsed
  results carry real success and failure outcomes.
- Measure only agent-* transcripts as Claude subagent streams; workflow
  journals below subagents/ are orchestration facts.
- Refuse to write a profile when no main stream was measured.
- Accept array-valued types inside anyOf/oneOf branches.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4
- Measure and render nested subagent spawns with their subagent parent
  instead of folding them into orphans.
- Weight the default origin mix by measured main-session populations.
- Guarantee a non-ASCII character in every text sampled into that class.
- Give integer-only ChatGPT timestamp fields integral defaults.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4
…rement

- Publish record-type values only when Polylogue's source adapters already
  name them; drop the file-count threshold so every profiled kind has a
  template (relocations keep relocatedCwd).
- Render tool-specific Claude Code inputs, drawn from the measured tool mix.
- Measure length and non-ASCII on the classified block's field, counting
  persisted-output results at their full size.
- Start nested Codex children inside their parent's lifetime; report Claude
  subagent ids as the parser composes them.
- Refuse to write over an earlier workload; default roots from the source
  registry; typed profile parsing.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4
…neage

Render Codex function-call arguments per tool (apply_patch as a patch that
names its path), keep public discriminator values such as a completion's
item.type in template skeletons, bind fork-context records to the generated
parent, start subagents inside the owner's stamped lifetime, allow the
profiled one-record Codex sessions, sample Read and other tool inputs from
per-tool length histograms, stream texts above 1 MiB instead of
materializing them, and refuse to write a profile whose main stream measured
no records.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01P8nGdByCWAzpk78ko2xza6

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a19f35cf02

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread polylogue/schemas/synthetic/workload.py Resolved
Comment thread devtools/schema_workload_profile.py Resolved
Comment thread polylogue/schemas/synthetic/workload.py Resolved
Sinity and others added 2 commits September 28, 2026 16:51
…ick only stamped Claude records

- workload.py: a custom_tool_call now samples its name from the profile's
  measured custom_tool_call: distribution (150k apply_patch vs 560k other)
  instead of always rendering apply_patch, so the generated tool-class mix
  matches what was measured instead of being 100% patches.
- schema_workload_profile.py: _count_shares now scans the whole measured
  text for non-ASCII characters instead of only its first 2000 characters,
  which systematically undercounted non-ASCII texts once the measured text
  ran past that prefix (real transcripts routinely do).
- workload.py: the Claude clock now advances only for a record that ends
  up carrying a timestamp. _claude_code_template's chosen skeleton can omit
  the timestamp key entirely (e.g. file-history-snapshot); ticking
  regardless still consumed a full sampled gap for that untimestamped
  record, inflating session durations whenever such templates occur.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
@Sinity

Sinity commented Sep 28, 2026

Copy link
Copy Markdown
Owner Author

Fixed all three findings in d257896:

  • custom_tool_call now samples its name from the profile's measured custom_tool_call: distribution (150k apply_patch vs 560k other) instead of always rendering apply_patch.
  • _count_shares now scans the whole measured text for non-ASCII characters instead of only the first 2000 chars.
  • The Claude clock now advances only for a record that ends up carrying a timestamp, since _claude_code_template's chosen skeleton can omit the key entirely.

Also checked the detached /realm/worktrees/claude-perf-gen worktree (bead 958ee) per the coordinator's note: its synthetic-generator-touching commits (wip(synthetic)/wip(bench), 8 of them) predate this branch's current state and are superseded — diffing perf-gen's synthetic/ files against this branch's head shows perf-gen is strictly behind (it lacks this branch's COVERAGE_EXTRA_KEY export/_wire_string_occurrences helper and other since-landed fixes); its one non-superseded addition, an _annotation_records helper in relation_solver_runtime.py, is dead code (defined, never called). Nothing from that worktree was cherry-picked.

Focused tests (test_synthetic_workload.py, test_schema_workload_profile.py) pass.

@Sinity
Sinity enabled auto-merge (squash) September 28, 2026 15:00

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d257896942

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread polylogue/schemas/synthetic/workload.py Resolved
Comment thread polylogue/schemas/synthetic/workload.py Resolved
Comment thread polylogue/schemas/synthetic/workload.py Resolved
Comment thread polylogue/schemas/synthetic/workload.py Resolved
Comment thread polylogue/schemas/synthetic/workload.py Resolved
Comment thread polylogue/schemas/synthetic/workload.py Resolved
Comment thread devtools/schema_workload_profile.py Resolved
Sinity and others added 2 commits September 28, 2026 17:26
_records() already returns list[dict[str, object]], so record is never
anything but a dict here; the isinstance guard was always true.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
Profiles (v2) record string lengths and list lengths per template field
path, so paths and contents keep their own sizes and lists their
measured cardinality; template fills name only envelope fields. Both
committed profiles are re-measured with the default sampling. Claude
results carry tool-specific evidence (edit fields, Agent agentId bound
to a generated child); Codex results never answer a call of the other
class, token subsets stay within their totals, and later session_meta
draws render the replayed header.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3541f59730

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread polylogue/schemas/synthetic/workload.py Resolved
Comment thread devtools/schema_workload_profile.py Resolved
Comment thread polylogue/schemas/synthetic/workload.py Resolved
Comment thread polylogue/schemas/synthetic/workload.py Resolved
Comment thread polylogue/schemas/synthetic/workload.py Resolved
Comment thread devtools/schema_workload_profile.py Resolved
Comment thread polylogue/schemas/synthetic/workload.py Resolved
Comment thread polylogue/schemas/synthetic/workload.py Resolved
Comment thread devtools/schema_workload_profile.py Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f4f569a2b4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread polylogue/schemas/synthetic/workload.py Resolved
Comment thread polylogue/schemas/synthetic/workload.py Resolved
Comment thread polylogue/schemas/synthetic/workload.py Resolved
Comment thread polylogue/schemas/synthetic/workload.py Resolved
Comment thread polylogue/schemas/synthetic/workload.py Resolved
Comment thread polylogue/schemas/synthetic/workload.py Resolved
Comment thread devtools/schema_workload_profile.py Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e455831066

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread polylogue/schemas/synthetic/workload.py Resolved
Comment thread polylogue/schemas/synthetic/workload.py Resolved
Comment thread polylogue/schemas/synthetic/workload.py Resolved
Comment thread devtools/schema_workload_profile.py Resolved
Comment thread polylogue/schemas/synthetic/workload.py Resolved
Comment thread polylogue/schemas/synthetic/workload.py Resolved
Comment thread polylogue/schemas/synthetic/workload.py Resolved
Comment thread polylogue/schemas/synthetic/workload.py Resolved
Sinity and others added 3 commits September 29, 2026 02:19
…cks, bound turn ids

Nesting is profiled as finite descendant and spawn distributions and
generated breadth first, so a long measured chain cannot recurse forever.
Template booleans render at their measured rate, deep public fields are kept,
and Claude tool-call messages keep their thinking and text blocks. A sampled
result with no open call is emitted unmatched. Codex template events bind
every turn carrier to the active turn, Claude agent_progress ticks name their
open dispatch, and byte targets count resolved sidecar references. Profiles
are regenerated at format v4.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c41b8b6d86

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread devtools/schema_workload_profile.py Resolved
Comment thread polylogue/schemas/synthetic/workload.py Resolved
Comment thread polylogue/schemas/synthetic/workload.py Resolved
Comment thread polylogue/schemas/synthetic/workload.py Resolved
Comment thread polylogue/schemas/synthetic/workload.py Resolved
Comment thread polylogue/schemas/synthetic/workload.py Resolved
Comment thread polylogue/schemas/synthetic/workload.py Resolved
Comment thread devtools/schema_workload_profile.py Resolved
Comment thread polylogue/schemas/synthetic/workload.py Resolved
Sinity and others added 3 commits September 29, 2026 03:53
…st shape, measure floats

Codex arguments, custom inputs, outputs and Claude call inputs are fitted so
the whole measured field (envelope and escaping included) has the sampled
size. Every tool_result block is profiled, companion blocks by multiplicity,
float leaves in thousandths, and list skeletons keep every distinct item
shape. Result messages keep their sampled cardinality with unmatched blocks,
envelope-bearing results are answered alone, and a spawned agent's metadata
names its spawning call. A malformed transcript line refuses the profile.
Profiles are regenerated at format v5.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
The per-kind companion tally reused the session's record counter, so a
session with companion blocks recorded a wrong length; the committed
profiles are regenerated. A fit whose trimmed characters were escaped
fell short of its sampled size; it now trims until it fits and makes up
a shortfall with unescaped characters.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@Sinity
Sinity merged commit eb3fad4 into master Sep 29, 2026
3 of 4 checks passed
@Sinity
Sinity deleted the claude/generator branch September 29, 2026 03:57
Sinity added a commit that referenced this pull request Sep 29, 2026
…#5678)

## Summary

Add `devtools bench fresh-build`, which builds a fresh archive from a
sealed source corpus through the ordinary daemon route and writes a
comparable receipt. The receipt covers stage timings, writer share,
queue depth, per-origin cost with a population projection, process-tree
RSS and CPU, time to promotion and to terminal convergence, terminal
checks, asserted budgets, and a per-table output fingerprint. `compare`
diffs two receipts and says whether their stored output is identical.
`components` times one production stage over the same corpus. An
in-daemon stack sampler stands in for py-spy, which cannot attach to
3.14t. The one-off whale qualification driver
(`devtools/daemon_finished_build.py`) is retired: a single large source
is now a `corpus files` corpus run with `--max-rss-mib`. A declared
`fresh_build_bench` AgentCTL operation runs it in the bulk pool.

## Problem

Nothing measured the fresh build the operator will actually run. The
existing finished-build measurements call
`backfill_historical_revision_evidence` directly and bypass intake, the
cold-build generation, promotion and derived convergence.
`devtools/daemon_finished_build.py` ran the real daemon, but only as a
pass/fail qualification for one input file. It had no stage attribution,
no comparison, and no corpus seal.

Running the new benchmark on a private 0.5% stratified sample of the
operator's sources (148 files, 290 MB, Claude Code/Codex/Gemini CLI) at
the base commit showed where a full build stands:
- Intake ran at 0.45 MiB/s. That projects to about 38 hours of intake
for the claude-code, codex and gemini-cli population alone (60 GiB).
- Mean CPU use was 0.34 cores. The writer was busy 45% of the time.
- An intake starvation bug (#5674), a promotion refusal
(`polylogue-se08w`), and derived stages that never converged kept the
build from finishing.

## Solution

- `corpus sample|files` lays sources out under a stand-in `$HOME`, so
the typed default sources resolve exactly as in production. The manifest
seals every file's path, size and SHA-256 under one digest, and the
sample is seeded and stratified by origin and size bucket.
- `run` isolates `HOME`, XDG and the archive root in the work directory.
It starts `polylogued run --no-browser-capture --no-api
--cold-build-index` with JSON events, samples the process tree once a
second, and polls the archive read-only. It stops on terminal
convergence, a stall, a settle timeout or SIGTERM, and the receipt is
written in every case. A cancelled job still leaves its evidence.
- Terminal means: promoted, every cursor complete or excluded, every
membership settled, zero convergence debt, and every required readiness
domain ready. `qualified` additionally requires zero raw parse failures,
exact FTS, and every asserted budget.
- `report --refresh` recomputes a receipt from its run directory, and
`profile` summarises the sampler's wall/CPU stacks.
- `docs/fresh-build-benchmark.md` documents corpora, running, the
receipt and how to read it.

## Verification

- `devtools test tests/unit/devtools/test_fresh_build_bench.py`: `8
passed` (receipt
`.cache/verify/runs/20260927T202649Z-focused-test-2750767-52bc166f`).
The tests cover the event-log reduction (intake window and writer share
scoped to promotion), leaf-only stage rollup, the population projection,
fail-closed budgets, the terminal predicate's readiness and membership
conditions, the corpus seal, and seeded session-unit sampling. Each
names its anti-vacuity mutation.
- `devtools gate
generated-surfaces|doc-commands|patterns|layering|oracle-integrity|test-packages`:
passed. `mypy devtools/fresh_build_bench/`: no issues.
- End to end on the private sample (numbers only; corpus and receipts
stay private): the receipts above, and later runs on the same corpus
after the fixes in #5674 and the follow-up performance PRs, compare
through this tool.

## Residual

- Synthetic corpora (`corpus synthetic`) arrive once the workload
generator in #5670 lands. Committed receipts should use them.
- Wall time on a shared host moves with load, and the receipt records
load at start. CPU seconds and writer holds are the steadier comparison.
- Whale qualifications for `polylogue-58bwo` are now runs of this
benchmark. They have not been run here.

## Self-review

I reviewed the complete diff at the final head: 146 review threads over
four rounds, re-read against the code rather than against the replies.
The findings are grouped by the property a receipt promises.

**A receipt is comparable only when its inputs are the same**
- The corpus manifest seals every file's path, size and SHA-256. The run
verifies the corpus before and after.
- Sampling uses production's own admission predicate
(`_is_supported_source_path`) plus the unit's sidecar directories.
- A full fraction copies every unit, zero-byte ones included.
- Each copy is verified against its source's content digest, and each
source is checked again against its copy's digest at the end of
sampling. File stamps alone missed a same-size rewrite within one
timestamp tick; this was found in the final review. The population
census is also recounted.
- The candidate is identified by git SHA, tracked-diff digest and a
stamp of every unignored file taken before and after the run. The
benchmark's own identity hashes the package, the fingerprint helper, and
the transitive closure of the `polylogue` modules it imports (absolute,
relative and submodule imports).
- The interpreter is probed from the candidate's working directory,
where the daemon is launched.

**A receipt says what happened, even on failure**
- The receipt is written atomically on every outcome: terminal, stall,
settle timeout, interrupted, or unreadable archive.
- An interrupted run skips the census and the fingerprint. SQLite
fingerprint passes are cancellable (progress handler,
`FingerprintCancelledError`).
- Shutdown waits while there is progress, measured as I/O counters and
event-log growth, not CPU, because the injected sampler keeps CPU
moving. There is no fixed deadline. The 8-hour AgentCTL ceiling is
recorded in polylogue-hesa2.
- The evidence digests cover `events.jsonl`, `ops.db` and `ops.db-wal`,
so `report --refresh` can tell whether it re-reads the same evidence.

**Qualification cannot be satisfied vacuously**
- Terminal requires all of: promotion, every cursor complete or
excluded, memberships settled, zero debt, and every required readiness
domain ready.
- `qualified` further requires:
  - zero raw failures;
  - exact FTS;
  - positive output;
- a steady wall clock, where clock steps are sampled every poll and the
largest counts;
  - complete sampler delivery;
  - a measured source timing for every sampled origin;
  - every asserted budget.
- Found in this last review and fixed with a receipt-level test: the
source-timing check read a projection key that does not exist (`origins`
instead of `by_origin`), so every `build_receipt` call raised. The unit
test had called the helper through the same wrong key. The new test
drives `build_receipt` end to end.

**Resource bounds**: component preparations keep at most 2×workers in
flight. The stack sampler keeps full-depth stacks, and its dump overhead
is reported.

**Verification**:
- `devtools test tests/unit/devtools/test_fresh_build_bench.py` on the
final head fb913b8: 102 passed, 0 failed.
`test_daemon_finished_build.py` is retired with its driver.
- `agentctl job start polylogue verify_quick` on the final head:
succeeded (job 2338).

**Residuals**:
- The projection is intake only. Promotion and derived convergence are
measured, not scaled.
- The receipts quoted under Problem were taken at the base commit on a
private sample and are not reproducible from this repository.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant