Repository navigation
fix: repair record_fact summary contracts and asset aliases - #282
Conversation
BaaRai
left a comment
There was a problem hiding this comment.
Thanks. The alias conflict handling and the per-item summary contract are right. The schema places anyOf at the root. The handler decodes without DisallowUnknownFields, so unknown keys are dropped. Blocking:
- Remove the root-level
anyOffrom the tool input schema. It reaches the provider unchanged; the handler already enforces "summary or facts". - Refuse unknown keys (
DisallowUnknownFieldsat top level and on items), and in batch mode reject top-level fields other thanintent_idandfacts, with an error naming the field. Note thatencoding/jsonmatches keys case-insensitively today, so the strict check should compare exact names. - Non-existent asset IDs currently surface to the model as a raw foreign-key error (SQLSTATE 23503). Please check that every anchor exists first and return a clear message.
Suggestions: a whitespace-only summary passes minLength: 1 but the handler rejects it; numeric-string asset IDs are accepted by the handler but rejected by the schema.
|
@BaaRai Addressed all three blockers in c833130, after merging current main.
I also aligned the schema with the handler for Unicode-whitespace-only summaries and numeric-string asset IDs. The existing per-item failure/retry behavior remains intact. Validation on the remote machine: complete agent/server/db suites with isolated PostgreSQL, |
BaaRai
left a comment
There was a problem hiding this comment.
Re-reviewed the rework. All three blockers are addressed: the root anyOf is gone from the generated, stored and repaired schemas; unknown keys are refused by exact name and DisallowUnknownFields, and batch mode only accepts intent_id and facts; the anchor check holds FOR KEY SHARE inside the insert transaction and reports the missing IDs instead of a foreign-key error. Aligning the schema with the handler for whitespace-only summaries and numeric-string asset IDs is a welcome extra. Thanks.
…cts and asset aliases
The schema the model sees for record_fact declared every fact field twice: at the top level (single-fact shape) and inside facts[] (batch shape), with the handler deciding which shape a call is. A model that fills every declared property sends the single fact inside facts[] and a copy, or a placeholder such as "", [] or "x", of each field beside it; since PR #282 every such call is refused by name, and the refusal text ("summary is not allowed at the top level") leads the model to send a dummy value next, so the same refusal repeats until the intent ends. Observed with a model over the OpenAI Responses API: 209 of 212 record_fact calls of two tasks were refused, 156 of them identical in one intent. The published schema is now {facts:[{...}]} and nothing else (required: facts, additionalProperties false). The handler keeps the strict contract of PR #282: unknown or mis-cased fields, invalid or foreign asset ids, missing summaries, empty batches and any top-level field beside facts (other than the legacy intent_id) are refused before anything is written, with an error that names the fields and the one accepted shape. It still accepts the legacy single fact and the legacy batch with a top-level intent_id. An item without intent_id is linked to the intent the worker is running (SetOwnerNode), as report_finding already does. record_fact opts out of the harness schema check (norma Spec.RawInput) so the stricter published schema does not reject the legacy shapes before the handler sees them; the catalog decorator forwards the opt-out. RepairRecordFactSchema republishes stored and cached schemas as facts-only and keeps the annotations of facts and its items. A one-time startup refresh replaces the stored description and the texts that referred to the top level when they equal the previous defaults; operator edits stay and are logged. seedFactSourceSchema adds the source enum on the items. Tests: the handler contract (TestRecordFactSummaryContract, TestRecordFactStrictFields, TestRecordFactBatchTopLevelConflicts, TestRecordFactRefusesTopLevelCopiesBesideFacts), the published schema and its repair (TestRecordFactSchemaIsFactsOnly, TestRecordFactStoredContractRepair, TestRecordFactInputSchemaUpgrade, TestRecordFactSourceSchemaUpgrade, TestWireTools), the running-intent default, the one-time refresh (TestRefreshRecordFactContract) and a synthetic replay of the call shapes (TestRecordFactShapesReplay). Co-Authored-By: Claude Mythos 5.1 <[email protected]>
Problem
record_factcan reject valid batch calls, hide failed items, or silently lose asset associations because its advertised schema and handler disagree.facts.itemsis currently an unconstrained object. The model is not told that every item needs its own non-emptysummary. A legacy/edited catalog schema requiring a top-levelsummarycan also reject a valid batch before the handler runs.{"summary":"TLS handshake observed","tested_asset_ids":[42]}records an unanchored fact on current main: Go silently discards the unrecognized field. Supplying conflictingasset_idsandtested_asset_idsis silently accepted.{"summary":"do not save","facts":[]}falls back to single mode and writes a fact. A JSON type error in a later item can still save earlier items because the unmarshal error is ignored. Item failures appear inside a nominally successful tool result.A deployment failure review motivated this change. That deployment additionally validates structured outcomes; upstream main does not contain that extension. This PR fixes the shared input-contract problems without introducing the deployment-specific outcome/revision workflow.
Resulting behavior
anyOf; the handler selects single or batch mode. Single calls requiresummary; batches require a non-emptyfactsarray with a non-emptysummaryon each item. Onlyintent_idinherits from the enclosing object.asset_idscanonical and accepttested_asset_idsas an alias. Normalize ordering/duplicates, retain numeric-string compatibility, reject invalid IDs and conflicting lists, and never infer assets from an intent or combine conflicting coverage.intent_idandfactsbefore any writes. Errors name the invalid field. Semantic per-item failures still retain successful results, setIsError, return aligned IDs/errors, and instruct callers to retry only failed indices.For example, this valid batch needs no redundant top-level summary:
{"facts":[{"summary":"TLS handshake observed","asset_ids":[42]}]}Benefits
These are correctness and retry-efficiency benefits; no percentage cost or latency improvement is claimed.
Validation
All work and checks ran on the remote machine against isolated test databases, with CPU/memory limits.
278de8b: alias-only inputs lose anchors, conflicting lists are accepted, empty batches write facts, malformed batches partially write, and legacy top-level summary requirements survive.go build -p 1 ./...— passed.go vet -p 1 ./...— passed.go test -p 1 ./agent ./server ./db -count=1— passed after merging upstreamac5e714.anyOf.