Skip to content

An unresolvable `$ref` is only caught on config paths the operator sets, so a typo on an omitted key still switches validation off silently

Id: TD-PPagop-26081606 · Status: resolved · Filed: 2026-08-16 · Resolved: 2026-08-16 · Ref: https://github.com/Poetic-Poems/agent-ops/pull/498

Issue #482 (resolved by PR #484) made deref in lib/config-schema.sh resolve a $ref to a bounded fixpoint and made config_schema_errors report an unresolvable or still-chained $ref as a fault instead of degrading it to “no constraints”. That closes the hole for every $ref the validator actually reaches — but the validator reaches a schema node only by walking into it, and errs’s object branch recurses over $v | keys_unsorted[] filtered to $s.properties: it descends only into keys the config sets. Both cycles gate on the raw config, before config_defaults runs (agent-cycle.sh:312, review-cycle.sh:130), so a $ref sitting on a property the operator has omitted is never resolved and its fault is never reported:

Terminal window
$ jq '.properties.schedule.properties.hours = {"$ref": "#/$defs/nope"}' \
config.schema.json > /tmp/s.json
$ jq 'del(.schedule)' config.json > /tmp/c.json
$ config_schema_errors /tmp/c.json /tmp/s.json; echo "rc=$?"
rc=0

Found in review of PR #484 (https://github.com/Poetic-Poems/agent-ops/pull/484#issuecomment-5306141208), and deliberately left out of that PR’s scope.

Most of config.schema.json’s properties are optional, so on a minimal config.json the majority of $ref sites are never resolved and a one-letter typo in any of them is exactly as silent as it was before #482 — additionalProperties: false stops applying to that subtree with no signal anywhere. #482’s own framing (“a typo in the schema should stop a cycle starting, exactly as an invalid config does”) holds only for keys the operator happens to have written out; the fault is a property of the schema, and the check that finds it is still a property of the config.

The reach also decides one narrow case where PR #484 is a small step backwards. For a property written {"$ref": "#/$defs/typo", "default": "x"} with the key absent, the pre-#484 one-hop deref left the sibling default in place (null + {default}), so config_defaults still applied "x"; the fixpoint deref throws instead and config_defaults’s catch null applies nothing — while config_schema_errors, per the above, still reports nothing. That shape does not occur in the shipped schema, and both halves go right together once the fault is caught schema-wide, which is why it is recorded here rather than fixed separately.

  • lib/config-schema.sh — config_schema_errors’s errs, whose object branch (($v | keys_unsorted[]) as $k | select(($s.properties // {}) | has($k))) is what bounds the walk to keys the config sets; config_defaults’s fill, whose (try deref(...) catch null) is the other half of the narrow case above.
  • docs/IMPLEMENTATION-PIPELINE-SPEC.md — requirement 1b’s $ref paragraph states this reach and names this item; the resolver updates it.
  • test/config-schema.test.sh — the $ref resolution block (issue #482) is where the coverage for a schema-wide sweep belongs.

Check the schema’s $refs against the schema, not against the config: have config_schema_errors sweep $root for every $ref and resolve each one, emitting a fault per unresolvable or over-deep chain regardless of whether any config key reaches it. The design question that kept this out of PR #484 is which subtrees are schema-space: a naive paths-based sweep cannot tell a schema node from a data node, so an object sitting inside a default, const or enum value that happened to carry a $ref key would be resolved as if it were a reference — and a false positive here fails both pipelines’ startup gate for every installation. Descending only through the keywords the validator itself understands (properties, items, $defs) rather than over all paths is the conservative shape, and has the side benefit of covering an items $ref under an empty array, which the config walk also misses today. Decide too whether a faulty $def that nothing references should stop a cycle: catching it is the point of a schema-wide sweep, but it is a stricter gate than #482 asked for. The fault’s message should keep naming where it was found, in schema space ($defs.label, properties.pr_label) rather than borrowing a config path it no longer has. Once it lands, the config_defaults asymmetry above needs no separate fix — but assert it, since nothing else would notice it returning.