Repository navigation
fix(microskills): guard parse_payload against wrongly-typed proposer fields - #198
Conversation
…fields - Handle extractors/facts as null (not just missing key) - Filter extractors with non-string pattern - Filter facts with non-dict detector - Guard _rx against non-string pattern input Fixes microsoft#173
Muhammad Abdullah Butt (1AbdullahButt)
left a comment
There was a problem hiding this comment.
I read parse_payload and everything that consumes its output at the PR head (_admit_extractor, _admit, _ground, DetectorV3Scope). The three cases in #173 are covered: "extractors": null now yields [], a non-string pattern is filtered out, and _rx returns None for a non-string instead of raising.
The same reply can still abort the fold, because a field that is not hashable crashes later in admission:
nameoridthat is a list or an object._admit_extractordoesspec["name"] in self.extractors(distiller.py:640), and_admitdoesfid not in self.facts(:689). With{"name": ["a"], "pattern": "x"}or{"id": ["f"], "detector": {}}, both raiseTypeError: unhashable type: 'list'.detector.scope/detector.firedthat is a list.DetectorV3Scope._lookupdoesname in self.features(:334) before it gets to the now-guarded_rx(name), so_groundraises the same TypeError.citethat is a number.for iid in (spec.get("cite") or [])(:657) raises'int' object is not iterable.
I checked the membership and iteration errors with a standalone snippet (['a'] in {}, for i in (3 or []): pass), not by running the distiller.
Requiring isinstance(e.get("name"), str) and isinstance(f.get("id"), str) in parse_payload closes 1. For 2 and 3, the simplest fix is to drop a fact whose detector has a non-string scope/fired/confirm/contradict, or whose cite is not a list. A test with each malformed reply, like the repro in the issue, would also keep this from coming back.
Reviewed with help from Claude Code.
…d cite fields A malformed proposer reply with a list or dict name or id crashed the extractor and fact admission on an unhashable key, and non-string detector fields crashed the feature lookup. Drop such entries in parse_payload, and treat a non-list cite as no citations.
|
Thanks Muhammad Abdullah Butt (@1AbdullahButt), pushed 30e07e0: |
`obj.get(...) or []` still iterated a truthy value that is not a list, so
{"extractors": true} or {"facts": 7} raised TypeError out of parse_payload
and aborted the fold (microsoft#173). The isinstance checks had also replaced the
truthiness checks, so an empty pattern or detector got through, and an
empty detector, which never grounds, took one of the MAX_CANDS slots.
The id cases now carry a real detector, so they reproduce the
unhashable-id crash in _admit on main instead of being dropped for their
empty detector. A new test checks that empty detectors no longer crowd
out a valid fact.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary
When the proposer returns wrongly-typed fields,
parse_payloadcrashes instead of filtering them out, causing the session to stay pending and retry the proposer on every session start.Changes
obj.get("extractors", [])returnsNone(not[]) when the key exists with valuenull. Changed toobj.get("extractors") or []patternfielddetectorfield_rx()against non-string inputTest plan
Inline verification:
Fixes #173