# Validate evaluator event-time state and implement durable trace replay Task ID: T-GCC-TRACE-019 Role: sol_implementer Status: READY ## 1. Context and baseline Shared root feat/implement-roadmap ca04975. User D-030 approved private GCC hooks and worker. Real evaluator and sealed Linux leaf capture 17/34 after a pause/step, 41/82 on edited input, and cancelled 125/failed 126. T-PLAN-GCC-008 and T-PREFLIGHT-GCC-008 cleared bounded control/replay. Two prior supervisor assignments returned HTTP 429 before writing files. Root implements Main.cpp, Supervisor.hpp/.cpp and owns frozen Trace.hpp. This package is the independent trace/replay portion only. ## 2. Objective and deliverables Implement a bounded event validator, one-use stop control, private append-only journal and offline historical reconstruction behind the actual new Trace.hpp. Provide direct focused tests, then real integration through the actual supervisor operated by root. ## 3. Scope and non-goals Pure copied event/source state plus local persistence, no process launch, stdout protocol or CLI, server, DAP or shared build config. This task implements the integral-return prototype and its recovery behavior. ## 4. Files to inspect Read experiments/frontend/gcc-worker/Trace.hpp, compiler-patches/gcc-16.2.0/0001-evaluator-events.patch (actual serialization), T-GCC-SUPERVISOR-018, tests/corpus/frontend/verify-gcc-events.py, Protocol/Json.hpp implementation in src/Protocol, build/voidlibrary/current/include/Void/Crypto/Crypto.hpp, docs/roadmap/19-trace-replay.md. Source files under current worktree are authoritative. ## 5. Write ownership and coordination Write scope: experiments/frontend/gcc-worker/Trace.cpp; tests/debug/TraceTests.cpp Use only those two tracked paths; root owns Trace.hpp, standalone main/supervisor, CLI and builds. For artifacts use your own ignored build/gcc-trace-tests. No Git ops, remote sends, sibling edits, child agents or shared package changes. ## 6. Implementation or investigation approach Validate bounded strict JSON v1 envelope, exact nonce and monotone integer seq. HELLO first expected version/backend/PID/capabilities: actual patch sends hello with 10 supported kinds. Require frame and parent on frame events, parent/top discipline, entered body then value (or cached); acknowledge actual matched control action for the correct stop before movement. Retain immutable copied integer precision, signed and lowercase bitsHex, distinguish unavailable and failing later cleanup. Track current active frames, provisional value, explicit partial and terminal reasons; don't infer values from names/sources. Preserve frame IDs even if nested calls or unexpected compiler ordering; check real event corpus (see witness test) before overconstraining. Read all docs for stdin control shape. A corrupt event must not advance state or poison last verified prefix. ## 7. Interfaces and data contracts Frozen API is Trace.hpp. create(output,source,compiler_sha,nonce,pid) exclusively creates a private journal (0600), hashes source, binds it+compiler identity to manifest, no overwrite. event(line without LF) validates and durably appends a complete record before publishing it to callers. authorize(stop,'step'|'continue'|'cancel') matches current unconsumed stop once, journals local command before return; stopped() then excludes consumed action while resumed remains required. ended() is true only after balanced frontendEnd. terminal() gives compiler terminal reason if any. inspection() returns owned JSON {nonce,sequence,stop,frames:[{frame,parent,name,value?,outcome?}],...}, inner frame last, sequence nullable before first event; integer value shape same as compiler. finish(outcome,exit_code,diagnostics) records verified process outcome separately; supported strings completed,failed,cancelled,truncated,expired. Completed requires genuine successful closed frontend, exit0. replay(journal,optional seq) returns same snapshot inspection including captured source, compilerSha256, sourceSha256, outcome and partial/corrupt status. seek returns state immediately after selected compiler event and before subsequent commands. Preserve read-only output with valid prefix on interruption. No arbitrary opens dictated by data in the file. ## 8. Dependencies and integration Implement the already-reviewed control/replay portion; no dependence on unfinished C++ supervisor for unit tests. Direct compile and test with C++26, small harness fixtures from captured real GCC event shapes. Notify root early if an actual wire mismatch affects integration. Root links implementations and performs real record/edit/replay after your handoff. ## 9. Edge cases security and performance Bound trace to actual 4096 events, ~1MiB payload, 4096 bytes per compiler frame, bounded source/diagnostic/metadata and command count. Use bounded file IO before allocation; corruption or truncation must not promote later records. Provide bounded record integrity, e.g. SHA-256 hash chained over length/previous record and exact bytes. Read only regular file; replay never executes commands or follows manifest paths. Handle short write, EINTR, concurrent or unsuccessful recording, partial tail and no in-place overwrite. Cap indexing and reconstruction memory; avoid copying all historical stacks per event. ## 10. Acceptance criteria Tests distinguish hello mismatch, bad ordinal/parent/frame, wrong integer bit length, stale/double control, resumed without command, cancellation prefix with open provisional frame, legitimate failed leave after provisional value, completion requires genuine wait outcome. Verify cursor snapshots and identical old source after disk edit/removal, truncation/tampering/replay-only without compiler, bounded corrupt line, exclusive create and no unintended artifacts. Root will exercise actual captured compiler stream+interactive supervisor separately. ## 11. Verification commands and evidence Use dev cpp-gcc -c g++ -std=c++26 -freflection -Iinclude -Ibuild/voidlibrary/current/include -fsyntax-only experiments/frontend/gcc-worker/Trace.cpp tests/debug/TraceTests.cpp; link dedicated runner with build/bootstrap/libvls_protocol.a and Void_Testing,Void_Crypto,Void_System,Void_LogState,pthread. Run --list --no-color then --no-color. Formatter dev cpp -c clang-format --dry-run --Werror on your two files. Keep any fixtures private. ## 12. Constraints and stop conditions Stop for incompatible schema/API or new security authority; notify parent before changing public path/field. Two unsuccessful repair attempts require changed hypothesis. If dependency data does not support claimed completed trace report the gap explicitly. Never perform user-facing release/IPC work under this assignment. ## 13. Authorization and decisions D-027 Max explicit gpt-6.2-sol for general implementation, D-029 reviewer remains Astra Max; D-030 approved local GCC experiment and deferred distribution. Root owns process integration and launch trust. ## 14. Return format T-GCC-TRACE-019 DONE/PARTIAL/BLOCKED, exact files/CLI independent API, journal format/limits, evidence commands, actual assertions and residual integration. Return early parser ready status when root can link.