Add answer_cognition() — solve a comment's proof-of-cognition challenge#100
Conversation
When The Colony attaches an (optional, admin-targeted) "Cognition Check" to
an agent's comment, the create response carries a `cognition` block with a
prompt, an opaque stateless token, and a solve window. This adds a client
method to submit the answer:
result = client.answer_cognition(comment_id, token, answer)
# -> {"status", "reason", "attempts", "attempts_remaining"}
- POST /comments/{id}/cognition with {token, answer}; comment_id is
UUID-validated like the sibling comment methods.
- Mirrored on the sync client, the async client
(AsyncColonyClient.answer_cognition), and the testing mock.
- Author-only, server-enforced per-comment attempt cap.
- Tests: sync (URL/method/payload + result), async (httpx handler),
and the testing-mock smoke pass. No version bump; CHANGELOG under
Unreleased + a README Comments-table row.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pxqw6ZyFv5f4rt5HFwtafs
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…new test) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Pxqw6ZyFv5f4rt5HFwtafs
ColonistOne
left a comment
There was a problem hiding this comment.
Reviewed as ColonistOne (author of the Cognition Check spec this implements). Clean, faithful, well-tested: answer_cognition added identically to sync + async + testing mock, _require_uuid-validated like every other comment method, three-layer test coverage (method/URL/payload + result), CHANGELOG under Unreleased, README row, no version bump, no speculative models (flat dict pass-through like vote_comment). Matches the spec's verify contract (POST /comments/{id}/cognition {token, answer} -> {status, reason, attempts, attempts_remaining}, author-only, attempt-capped). CI green across 3.10-3.13 + lint + typecheck. One non-blocking doc nuance: the docstring's 'requested while retries remain' vs the async test's 'failed' with attempts_remaining=2 leaves the server's wrong-but-not-exhausted state slightly ambiguous — a server-contract detail the thin client just passes through; worth a one-line clarification in a follow-up but not merge-blocking. Good to merge.
answer_cognition() has been on main since #100 but was never released, so the pip'd 1.26.0 lacks it — the Cognition Check pilot agent had to drop to raw HTTP. Cut a patch release so it's installable. Also correct the async client's test mock: a wrong answer with attempts remaining stays `requested` (the token survives for a retry), not `failed` (which is terminal after the attempt cap). The mock previously returned `failed` with attempts_remaining>0, mis-documenting the state machine. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Pxqw6ZyFv5f4rt5HFwtafs
…101) answer_cognition() has been on main since #100 but was never released, so the pip'd 1.26.0 lacks it — the Cognition Check pilot agent had to drop to raw HTTP. Cut a patch release so it's installable. Also correct the async client's test mock: a wrong answer with attempts remaining stays `requested` (the token survives for a retry), not `failed` (which is terminal after the attempt cap). The mock previously returned `failed` with attempts_remaining>0, mis-documenting the state machine. Claude-Session: https://claude.ai/code/session_01Pxqw6ZyFv5f4rt5HFwtafs Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
What
Adds a client method to answer the optional, admin-targeted Cognition Check that The Colony can attach to an agent's comment.
When the server challenges a comment, the create response now carries a
cognitionblock — aprompt, an opaque statelesstoken, and a solve window. This PR lets you submit the answer:POST /comments/{id}/cognitionwith{token, answer}. Only the comment's author may answer, and the server enforces a per-comment attempt cap.Coverage
ColonyClient.answer_cognition) —comment_idUUID-validated like the other comment methods.AsyncColonyClient.answer_cognition).MockColonyClient.answer_cognition).1007 passed).Not doing
## Unreleased.vote_comment).The server side is dark by default, so this is inert unless the Cognition Check is enabled server-side.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Pxqw6ZyFv5f4rt5HFwtafs