Preserve authoritative nested model trajectory events #139

Merged
lost-rob0t merged 9 commits from fix/45-authoritative-nested-model-events into main 2026-08-21 02:04:34 +00:00
lost-rob0t commented 2026-08-21 01:54:06 +00:00 (Migrated from github.com)

Closes #45.

Summary

Preserves every executed plan-model event from the authoritative execution state instead of reconstructing completion trajectories from final lexical vars.

Runtime invariant

One append-only execution record now drives both nested model accounting and trajectory projection. Lexical scope restoration may hide child vars, but it cannot erase executed provider observations or rewrite their true depth.

Implementation

  • extend rlm_plan execution state with an append-only model_events ledger alongside the existing #43 model_responses ledger;
  • assign deterministic execution-order IDs (plan_model_N) and preserve parent lineage, depth, reason, provider and raw response at call time;
  • carry trace scope through nested rlm, parallel branches and retries, restoring lexical/trace scope without restoring either append-only ledger;
  • expose ordered model events on successful plan results and execution errors;
  • make rlm_completion project authoritative recorded events first, retaining the legacy final-vars reconstruction only for older result shapes without model_events;
  • preserve selected model, HTTP status and usage from the recorded response when producing public model_event terms;
  • reconcile TODO.md with merged #42/#44/#46/#67 state and this #45 slice.

TDD / verification

Regression coverage proves:

  • execution-time recording produces stable IDs and parent links at true depths 0/1/2;
  • nested response/event ledgers preserve deterministic order;
  • completion consumes authoritative events even when nested responses are absent from Result.vars;
  • provider, selected model, HTTP status, reason and usage survive projection;
  • visible final vars cannot silently collapse or reorder the authoritative event sequence.

Exact-head GitHub Actions remains authoritative. Deterministic PlUnit, benchmark/deep-recursion, CLI/trace, persistence/restart, REAL OpenRouter and Tree-sitter gates must all pass before merge.

Non-goals

  • no second executor, scheduler or trace store;
  • no change to model-call budgets or recursion gating;
  • no weakening of #53 authority, #54 async or #57 effect semantics;
  • no claim that later architecture tracks are v0.1 blockers.
Closes #45. ## Summary Preserves every executed plan-model event from the authoritative execution state instead of reconstructing completion trajectories from final lexical vars. ## Runtime invariant One append-only execution record now drives both nested model accounting and trajectory projection. Lexical scope restoration may hide child vars, but it cannot erase executed provider observations or rewrite their true depth. ## Implementation - extend `rlm_plan` execution state with an append-only `model_events` ledger alongside the existing #43 `model_responses` ledger; - assign deterministic execution-order IDs (`plan_model_N`) and preserve parent lineage, depth, reason, provider and raw response at call time; - carry trace scope through nested `rlm`, parallel branches and retries, restoring lexical/trace scope without restoring either append-only ledger; - expose ordered model events on successful plan results and execution errors; - make `rlm_completion` project authoritative recorded events first, retaining the legacy final-vars reconstruction only for older result shapes without `model_events`; - preserve selected model, HTTP status and usage from the recorded response when producing public `model_event` terms; - reconcile `TODO.md` with merged #42/#44/#46/#67 state and this #45 slice. ## TDD / verification Regression coverage proves: - execution-time recording produces stable IDs and parent links at true depths 0/1/2; - nested response/event ledgers preserve deterministic order; - completion consumes authoritative events even when nested responses are absent from `Result.vars`; - provider, selected model, HTTP status, reason and usage survive projection; - visible final vars cannot silently collapse or reorder the authoritative event sequence. Exact-head GitHub Actions remains authoritative. Deterministic PlUnit, benchmark/deep-recursion, CLI/trace, persistence/restart, REAL OpenRouter and Tree-sitter gates must all pass before merge. ## Non-goals - no second executor, scheduler or trace store; - no change to model-call budgets or recursion gating; - no weakening of #53 authority, #54 async or #57 effect semantics; - no claim that later architecture tracks are v0.1 blockers.
Sign in to join this conversation.
No description provided.