mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #5281] [CLOSED] feat(agents): validate Beholder extractions before they reach state #6705
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#6705
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/5281
Author: @GetBeholder
Created: 8/19/2026
Status: ❌ Closed
Base:
staging← Head:feat/beholder-validator📝 Commits (4)
ce94ca0feat(agents): validate Beholder extractions before they reach state2a7485bstyle(agents): format the vendored validator tables11a4e7dMerge branch 'staging' into feat/beholder-validator5153a98Merge branch 'staging' into feat/beholder-validator📊 Changes
6 files changed (+4923 additions, -9 deletions)
View changed files
📝
packages/server/src/services/agents/agent-executor.ts(+31 -4)📝
packages/server/src/services/agents/beholder-state.ts(+19 -5)➕
packages/server/src/services/agents/beholder-validator-data.ts(+1251 -0)➕
packages/server/src/services/agents/beholder-validator.ts(+760 -0)➕
scripts/regressions/beholder-validator-cases.json(+2784 -0)➕
scripts/regressions/beholder-validator-parity.regression.ts(+78 -0)📄 Description
Linked issue
No separate issue — continues the Beholder parity work behind #5251 and #5280. Stacked on #5280; review that first, and this diff is validator-only once #5280 lands.
Why this change
Beholder has no runtime validation. Output is schema-clamped — unknown slots dropped, enums coerced — and then merged. So anything well-formed is accepted, and well-formed is not the same as possible:
backleft_hand"pureblood"stored as a speciesAll four survive schema clamping today. And they do not stay contained: tracked state is fed back into the next extraction and into the next roleplay response, so one impossible entry keeps being restated until a user hand-edits it.
This matters more here than for a typical agent because the extractor is deliberately small. The reference implementation treats runtime validation as mandatory for exactly that reason.
What changed
beholder-validator.ts(new) — port of the validator from the reference extractor, itself a mirror of the validator that produced Beholder's training labels. 25 rules across anatomy, species, multi-slot garments, mutually exclusive clothing, missing-limb dominance and cascade, plus prose-aware severity and damage checks. Error-severity findings strip the offending path (deepest first, then descending list index so same-list strips don't shift each other); warnings and suggestions are reported only.beholder-validator-data.ts(new) — the constant tables, vendored verbatim from the generated source so they stay diffable and cannot drift by hand-editing.agent-executor.ts— validation runs atresolveStructuredAgentResult, the single point every Beholder path already funnels through, so the single-prompt and per-lane shapes are both covered. Findings are logged at debug with rule and path.beholder-state.ts— the persona-as-selfkeying is extracted so the prompt and the validator see the same shape (the validator compares a delta against prior state, so it must be keyed like the delta).No schema, storage, API, or client change.
Validation
node scripts/validate-catalog.mjspasses locallygit diff --checkpasses locallyCONTRIBUTING.mdManual verification notes
Those boxes are the package template's and do not apply — this is Engine code, no package touched.
pnpm installalso fails in my environment at theonnxruntime-nodepostinstall (it rejects CUDA 13), so I cannot run the fullpnpm checkor the app.What I did run:
scripts/regressions/beholder-validator-parity.regression.ts(new) runs the port against the fixture generated from the source validator, vendored unchanged, and compares both the findings (rule id, path, severity) and the full stripped delta: 60/60 cases match. Comparison is scoped to the ported rule set, so a rule the port has not taken on shows as a gap rather than a false mismatch.tsc -b ../shared && tsc --noEmitforpackages/server→ 0 errors. Prettier clean.beholder-normalizer,beholder-user-message,beholder-lane-passesandbeholder-wound-mergeregressions still pass.Not verified: behaviour against a live model. The judgement worth a maintainer's eye is that error-severity findings strip silently (reported at debug level, not surfaced in the UI) — that is the reference behaviour, but a user seeing an item quietly not appear has no in-app explanation yet. Surfacing findings is a natural follow-up.
Summary by CodeRabbit
New Features
Bug Fixes
Tests
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.