Skip to content

Constrain --agent to the detector's own vocabulary - #749

Open
simonheimlicher wants to merge 1 commit into
onevcat:mainfrom
silvarbor:validate-agent-flag-against-vocabulary
Open

Constrain --agent to the detector's own vocabulary#749
simonheimlicher wants to merge 1 commit into
onevcat:mainfrom
silvarbor:validate-agent-flag-against-vocabulary

Conversation

@simonheimlicher

Copy link
Copy Markdown

Follow-up to the review comment on #702. --agent is required but unvalidated, so every value that is not exactly claude takes the bounded-tail branch:

return text if agent == "claude" else canonical_tail(text)

--agent Claude therefore reduces a Claude capture to 24 lines and says nothing. That is the loss the flag was added to prevent, and a trimmed screen is a plausible screen, so no later step can catch it. Two of the runtime names are also not the case name, cursor-agent and qodercli, so a wrong value is not only a typo risk.

choices=DETECTED_AGENTS turns it into an argparse error and puts the accepted names in --help.

The list is a hand copy of DetectedAgent, which is the part that rots. A test parses the enum out of DetectedAgent.swift and compares, so the copy fails the build rather than drifting, in the same shape as AgentScreenRuleCoverageTests. A second test pins the rejection end to end.

make check passes, 78 script tests.

The flag was required but unvalidated, so every value that was not
exactly `claude` took the bounded-tail branch. A capture reduced with
`--agent Claude` lost the rows above the tail without saying so, which
is the data loss the flag was added to prevent, and a trimmed screen
is a plausible screen so nothing downstream could notice.

Two of the runtime names are not the case name — `cursor-agent` and
`qodercli` — so a wrong value is not only a typo risk.

`choices` turns it into an argparse error. The list is a hand copy of
`DetectedAgent`, so a test parses the enum and fails when the two
drift, and an end-to-end test pins the rejection.

@onevtail onevtail left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The argparse choices correctly fix the reported failure mode: unknown agent names such as Claude now exit with status 2 instead of silently producing a truncated fixture.

There is one blocking mismatch for the newly accepted pi value. Production keeps 32 non-empty lines for Pi, while this script still applies the default 24-line limit. For a 40-line capture, --agent pi currently emits row 16 through row 39; the production-equivalent result is row 8 through row 39. The corpus check cannot detect this after truncation because applying a 32-line tail to an already truncated 24-line fixture leaves it unchanged.

Please align the Python reduction logic with the production rules (Claude/full, Pi/32, default/24), add coverage for those three categories, and update the help text and fixture README accordingly.

The enum synchronization test also stops parsing at var id:. Swift permits cases after a computed property, so a later case could drift without failing this test. Please either parse the complete enum body or explicitly assert that no cases occur after that point.

onevtail - an assistant to @onevcat

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