Trace System Architecture¶
Implementation map for the contracts in docs/contracts/BLUEPRINT.md.
1) Runtime Layers¶
src/trace_tasks/core/— deterministic infrastructure: types, hashing, seeds, taxonomy, validation, build, reward contracts, reward scoring, and export.src/trace_tasks/core/prompts/— prompt bundle loading, validation, selection, and rendering.src/trace_tasks/core/visual/— deterministic shared background and post-image noise.src/trace_tasks/tasks/— task registry plus concrete task implementations.src/trace_tasks/tasks/shared/— cross-domain task helpers.src/trace_tasks/tasks/<domain>/shared/— domain-wide helpers only when reused across multiple scenes in that domain.src/trace_tasks/tasks/<domain>/<scene_id>/— current-layout task files and scene-localshared/helpers.src/trace_tasks/resources/prompts/— external prompt assets.src/trace_tasks/resources/configs/— packaged generation and rendering defaults;examples/configs/contains example build configurations.
All active task work uses the current source layout described in
docs/contracts/SOURCE_LAYOUT.md.
2) Runtime Data Flow¶
- Load build config and type registry.
- Resolve deterministic
dataset_id. - Sample a public
task_id. - Generate staged instances:
- explicit task params from build config,
- task-local query sampling,
- public taxonomy resolution (
domain -> scene_id -> task_id), - scene/task/query prompt rendering,
- image rendering and visual variation,
- answer and annotation binding from the same execution trace,
- reward-contract resolution from public answer/annotation types,
- sidecar trace write,
- train-record write with
trace_ref. - Optionally run strict-repro second pass and compare.
- Run pre-finalize validation.
- Write
validation_report.jsonandbuild_report.json. - Atomically finalize on success; persist failure bundle on error.
3) Core Module Responsibilities¶
Core Runtime¶
src/trace_tasks/core/types.py— ABI dataclasses.src/trace_tasks/core/canonical.pyandsrc/trace_tasks/core/hash_utils.py— canonical hashing.src/trace_tasks/core/seed.py— seed derivation and spawn helpers.src/trace_tasks/core/identity.py—instance_idcomputation.src/trace_tasks/core/type_registry.py— answer/annotation type checks.src/trace_tasks/core/trace_store.py— sidecar trace shard I/O.src/trace_tasks/core/validation.py— pre-finalize dataset validation.src/trace_tasks/core/builder.py— build orchestration.src/trace_tasks/core/build_presets.py— reusable build recipes.src/trace_tasks/core/reward_contracts.py— public reward-contract resolver.src/trace_tasks/core/reward_scoring.py— shared Trace answer/annotation scoring.src/trace_tasks/core/rlvr_export.py— Trace-to-RLVR export helpers.src/trace_tasks/core/taxonomy.py— public taxonomy and implementation/source routing metadata.src/trace_tasks/core/strict_repro.py— strict reproducibility comparisons.src/trace_tasks/core/scene_config.py— config resolver for scene defaults.src/trace_tasks/core/sampling.py— shared sampling primitives.src/trace_tasks/core/json_io.py— deterministic JSON writing.
Prompt And Visual¶
src/trace_tasks/core/prompts/assets.py— prompt bundle loading/cache.src/trace_tasks/core/prompts/schema.py— prompt schema validation.src/trace_tasks/core/prompts/select.py— deterministic variant selection.src/trace_tasks/core/prompts/render.py— strict rendering and metadata.src/trace_tasks/core/visual/background.py— background style selection/rendering.src/trace_tasks/core/visual/noise.py— post-image noise selection/application.src/trace_tasks/core/visual/defaults.py— visual defaults loading.
Task Framework¶
src/trace_tasks/tasks/registry.py— registration and creation.src/trace_tasks/tasks/base.py— task protocol andTaskOutput.src/trace_tasks/tasks/shared/*— cross-domain query, layout, annotation, config, prompt, and output helpers.src/trace_tasks/tasks/<domain>/<scene_id>/<objective_contract>.py— one public task file per active task.src/trace_tasks/tasks/<domain>/<scene_id>/shared/*— scene-local reusable state, sampling, rendering, prompt-slot, annotation, and output helpers.src/trace_tasks/tasks/<domain>/shared/*— helpers reused by multiple scenes in one domain, never a dumping ground for one scene's task routing.
4) Active Task Inventory¶
The active public task surface is generated from the live registry and taxonomy. Do not enumerate current tasks or scenes in this architecture doc.
Use docs/ACTIVE_TASK_INVENTORY.md for the committed generated inventory of
domain -> scene_id -> task_id. Regenerate it with:
python scripts/generate_active_task_inventory.py
5) Architecture Invariants¶
- Determinism from config, seeds, code versions, prompt assets, and visual assets.
TrainInstancestays lightweight; heavy replay metadata stays in sidecar trace.- Public records expose
domain,scene_id, and task identity. Source routing metadata is debug/runtime metadata only. - Answer, annotation, and witness metadata are consistent from one execution trace.
- Shared helpers are reused before adding task-local utilities, but shared code must stay identity-free.
- Public task files own objective-specific construction, answer binding,
annotation binding, prompt slots, trace payload, and final
TaskOutput. - Builder parallelism changes throughput only; dataset identity and finalized row ordering stay invariant for fixed build-critical config.
6) When To Update This Doc¶
Update when module boundaries, build lifecycle, shared invariants, or extension points change. Do not update this doc for ordinary task additions/removals; use the generated inventory and domain/task docs instead.