Skip to content

fix(observe): emit freshness on the wire, not verdict - #2

Merged
trakhimenok merged 1 commit into
mainfrom
fix/observe-freshness-rename
Jul 25, 2026
Merged

fix(observe): emit freshness on the wire, not verdict#2
trakhimenok merged 1 commit into
mainfrom
fix/observe-freshness-rename

Conversation

@trakhimenok

Copy link
Copy Markdown
Contributor

Summary

  • wireValidation in src/run/bundle.ts still emitted the old verdict field name, so every browser-written run bundle was invalid against the published formats/run-bundle/v1/schema.json (freshness is required there) and disagreed with Go-written bundles on a field name — a principle 7 violation ("one scenario file, two runtimes, same verdict").
  • Renames the observe-side click-validity concept throughout: Verdict -> Freshness (values fresh/stale unchanged), ValidationResult.verdict -> .freshness, ValidationOutcome.verdict -> .freshness, and every call site (observe/engine.ts, actor/loop.ts, actor/loop-event.ts, actor/openai/prompt.ts, run/report.ts, run/bundle.ts) and test.
  • Refreshes the vendored schema fixture src/session/__fixtures__/run-bundle.v1.schema.json from the canonical chatwright/chatwright copy — confirmed byte-identical after the copy.
  • Leaves deterministic/assertions.ts's AssertionVerdict (pass/fail/unverified) untouched — that one is correctly named, a genuinely different concept (AI-judged assertion outcome vs. the runtime's own click-validity check).

Verification

Before touching wireValidation, refreshed only the vendored schema and reran src/run/greetbot.e2e.test.ts: it failed (freshness required by schema, verdict still on the wire) — confirming the stale vendored schema, not the code, is why CI hadn't already caught this. After the full rename, the same test (and the full suite) passes.

  • pnpm vitest run — 20 files, 187 tests passed
  • pnpm tsc --noEmit -p tsconfig.json — clean, exit 0
  • Vendored schema confirmed byte-identical to chatwright/chatwright's formats/run-bundle/v1/schema.json
  • Grepped src/ for remaining verdict/Verdict — only AssertionVerdict and generic English "verdict" in doc comments about assertion verification remain (out of scope, correctly named)

Note for Studio

Studio vendors this package by pinned commit SHA (scripts/vendor-runtime.mjs); this PR does not bump it. A SHA bump is needed there once this merges, so Studio-emitted bundles also write freshness.

🤖 Generated with Claude Code

https://claude.ai/code/session_01SkkrXdtf8mU2GRo2hHsHT1

wireValidation in run/bundle.ts still wrote the old verdict field name,
so every browser-written bundle was invalid against the published
run-bundle v1 schema (freshness is required) and disagreed with
Go-written bundles on a field name. Renames the observe-side type and
field throughout (Verdict -> Freshness, ValidationResult.verdict /
ValidationOutcome.verdict -> .freshness) to match sdk-go v0.3.0,
runtime-go v0.5.0 and cli v0.6.0, and refreshes the vendored schema
fixture from the canonical formats/run-bundle/v1/schema.json (it was
stale in exactly the same way, which is why the schema-validation test
did not already catch this).

AssertionVerdict in deterministic/assertions.ts is left untouched: it
is a genuinely different concept (an AI-judged assertion outcome), not
the runtime's own click-validity check.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SkkrXdtf8mU2GRo2hHsHT1
Signed-off-by: Alexander Trakhimenok <alex@trakhimenok.com>
@trakhimenok
trakhimenok requested a review from Copilot July 25, 2026 10:39
@trakhimenok
trakhimenok merged commit bafc9a9 into main Jul 25, 2026
3 checks passed

Copilot AI 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.

Pull request overview

This PR aligns the TypeScript runtime’s observe/validation terminology and wire format with the published run-bundle v1 schema by renaming the click-validity concept from verdict to freshness (values remain fresh/stale). This ensures browser-written bundles validate against the schema and match Go-written bundles on the field name.

Changes:

  • Renamed observe-side validation types/fields from Verdict/verdict to Freshness/freshness across the runtime and call sites.
  • Updated run-bundle wire serialisation to emit freshness instead of verdict.
  • Refreshed the vendored run-bundle v1 schema fixture and updated affected tests accordingly.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/session/fixtures/run-bundle.v1.schema.json Updates schema fixture to require/describe freshness rather than verdict.
src/run/report.ts Updates report logic to interpret validation via validation.freshness.
src/run/report.test.ts Adjusts report test data to use freshness.
src/run/bundle.ts Fixes wire serialisation to emit freshness on the wire.
src/observe/observe.ts Renames public observe types/fields (VerdictFreshness, verdictfreshness) and updates docs.
src/observe/observe.test.ts Updates observe validation tests to assert freshness.
src/observe/engine.ts Updates engine validation result shape to return freshness and updates docs.
src/actor/openai/prompt.ts Updates prompt history rendering to print validation.freshness.
src/actor/loop.ts Updates loop validation plumbing to carry freshness and branch on it.
src/actor/loop.test.ts Updates loop stale-click test to check freshness.
src/actor/loop-event.ts Renames loop event validation field/type usage to Freshness/freshness.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/observe/engine.ts
* Checks `proposal` against the Engine's CURRENT journal state — never
* against the (possibly outdated) Observation the actor originally saw —
* and returns a deterministic fresh/stale verdict with a reason. It does
* and returns a deterministic fresh/stale freshness with a reason. It does
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.

2 participants