Skip to content

fix(canonical): call Result.is_ok/is_err as properties#1218

Merged
Q00 merged 1 commit into
Q00:mainfrom
shaun0927:fix/canonical-result-property-api
May 25, 2026
Merged

fix(canonical): call Result.is_ok/is_err as properties#1218
Q00 merged 1 commit into
Q00:mainfrom
shaun0927:fix/canonical-result-property-api

Conversation

@shaun0927
Copy link
Copy Markdown
Collaborator

Summary

  • tests/canonical/test_canonical.py:248-252 was calling result.is_ok() and result.unwrap_err() as methods, but Result.is_ok/is_err are @property accessors in src/ouroboros/core/types.py:70-78 and unwrap_err does not exist (only the .error property at line 102 exposes the err side).
  • Live canonical runs (OUROBOROS_RUN_CANONICAL=1 pytest tests/canonical/) therefore raised TypeError: 'bool' object is not callable before any production failure evidence could surface — masking real regressions in ooo auto behind a test-harness type error.
  • This bug was introduced in feat(tests): L0 live-wire + L1 catalog cross-validate (P1) #1191 and was never exercised because the live canonical lane is opt-in.

Why this matters

R1 evidence (gathered locally on 265aedb4) shows that ooo auto cli-todo is currently BLOCKED at safe-default closure (separate regression; tracked in a follow-up issue). That blocker is only readable after this harness fix lands, otherwise pytest dies at the is_ok() call site before the AutoPipelineState/MCP envelope can be inspected.

Test plan

  • uv run pytest tests/canonical/ -v (canonical live OFF, $0 token cost) — 17 passed, 1 skipped
  • CI green
  • (follow-up, separate PR/issue) OUROBOROS_RUN_CANONICAL=1 pytest tests/canonical/ -k cli-todo — surfaces the real phase=blocked evidence instead of TypeError

🤖 Generated with Claude Code

Result.is_ok and Result.is_err are @Property, and Result has no
unwrap_err method — only the .error property. The canonical live-run
assertion was calling them as methods, so OUROBOROS_RUN_CANONICAL=1
raised TypeError before any failure evidence could surface.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@ouroboros-agent ouroboros-agent Bot left a comment

Choose a reason for hiding this comment

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

Review — ouroboros-agent[bot]

Verdict: APPROVE

Metadata

| Field | Value |
|### Recovery Notes
First recoverable review artifact generated from codex analysis log.

---|---|
| PR | #1218 |
| HEAD checked | 1f7dc10993e7119e4fe40e942cf649f5b5fb8eef |
| Request ID | req_1779699687_2 |
| Review record | 99af50e3-805e-4c50-9179-97f01d52b501 |

What Improved

  • Fixes the opt-in canonical live-run test to use the project’s property-based Result API (is_ok, is_err, error) instead of calling removed/nonexistent method-style helpers.

Issue Requirements

Requirement Status
No linked issue requirement captured N/A

Prior Findings Status

No prior human or inline review concerns were present in the supplied comment artifacts.

Blockers

No in-scope blocking findings remained after policy filtering.

Follow-up Findings

# File:Line Priority Confidence Suggestion
1 None None High None.

Non-blocking Suggestions

| 1 | None | None | None. |

Test Coverage Notes

  • Reviewed /tmp/pr_diff_1218.patch, changed-files list, canonical test harness, AutoHandler.handle(), and ouroboros.core.types.Result.
  • Could not execute pytest in this container: python is missing, python3 is 3.11 while the project requires >=3.12 and .python-version is 3.14, and pytest is not installed for python3.

Design Notes

The change aligns the canonical live-run assertion with the repository-wide Result contract and does not alter runtime behavior.

Design / Roadmap Gate

Affected boundary is the test-to-MCP-handler contract: _invoke_ouroboros_auto() returns AutoHandler.handle()’s Result[MCPToolResult, MCPServerError], whose API exposes is_ok, is_err, and error as properties. The updated assertion matches that contract. No persistence, replay, compatibility, or production runtime boundary changes are introduced.

Directional Notes

Maintainer memory emphasized evidence-based evaluation review. I focused on whether the changed test accurately exercises the MCP handler result boundary and whether it weakens canonical evidence; no current-HEAD blocker was found.

Test Coverage

  • Reviewed /tmp/pr_diff_1218.patch, changed-files list, canonical test harness, AutoHandler.handle(), and ouroboros.core.types.Result.
  • Could not execute pytest in this container: python is missing, python3 is 3.11 while the project requires >=3.12 and .python-version is 3.14, and pytest is not installed for python3.

Merge Recommendation

Approve. The patch is a narrow correction to a skipped-by-default live canonical test and matches the current Result API.

Review-Metadata:
verdict: APPROVE
head_sha: 1f7dc10
request_id: req_1779699687_2
review_profile: memory-aware-zero-trust-v2
advisory_memory_only: true


Reviewed by ouroboros-agent[bot] via Codex deep analysis

@shaun0927
Copy link
Copy Markdown
Collaborator Author

Coordination note re: #1214

PR #1214 (also OPEN, also editing tests/canonical/test_canonical.py) adds a local _Ok test stub:

class _Ok:
    def is_ok(self) -> bool:   # method, not property
        return True
    def unwrap_err(self) -> str:  # nonexistent on Result
        return "unexpected"

That stub is shape-incompatible with the real Result API in src/ouroboros/core/types.py:70-78,102is_ok/is_err are @property and there is no unwrap_err. The stub appears to have been written against the same broken call-site this PR fixes, so it would silently mask future regressions of the same shape.

If this PR lands first, the _Ok stub in #1214 should be updated before merge to use property accessors (or replaced with a Result.ok(...) instance). If #1214 lands first, the stub is still wrong and should be fixed alongside or in a follow-up; this PR's substantive 2-line fix to the live-run assertion remains independent.

cc reviewers of #1214 for awareness.

Copy link
Copy Markdown
Contributor

@ouroboros-agent ouroboros-agent Bot left a comment

Choose a reason for hiding this comment

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

Review — ouroboros-agent[bot]

Verdict: APPROVE

Metadata

| Field | Value |
|### Recovery Notes
First recoverable review artifact generated from codex analysis log.

---|---|
| PR | #1218 |
| HEAD checked | 1f7dc10993e7119e4fe40e942cf649f5b5fb8eef |
| Request ID | req_1779699995_3 |
| Review record | eeb6a290-67ab-4c9c-bc55-eaacad33f99a |

What Improved

  • Fixes the live canonical harness assertion to use the real Result API: is_ok/is_err properties and error instead of nonexistent method-style accessors.

Issue Requirements

Requirement Status
No linked issue requirement captured N/A

Prior Findings Status

No inline prior review comments were present. The PR comment about #1214 was treated as coordination context only; it does not create a blocker for this PR.

Blockers

No in-scope blocking findings remained after policy filtering.

Follow-up Findings

# File:Line Priority Confidence Suggestion
1 tests/canonical/test_canonical.py:248 Low Medium Consider adding a tiny unit-level assertion around the live-run result failure formatting if this path gets more logic; for this PR’s two-line contract fix, the current source-level API match is sufficient.

Non-blocking Suggestions

| 1 | tests/canonical/test_canonical.py:248 | Test environment | I could not execute the focused pytest module locally because pytest is not installed in the review container (python3 -m pytest tests/canonical/test_canonical.py failed with No module named pytest). |

Test Coverage Notes

  • Reviewed tests/canonical/test_canonical.py, tests/canonical/conftest.py, and src/ouroboros/core/types.py.
  • Confirmed AutoHandler.handle() returns Result[MCPToolResult, MCPServerError], and Result.is_ok, Result.is_err, and Result.error are the correct public API.
  • Attempted focused test run, but local pytest dependency is unavailable in the snapshot environment.

Design Notes

The change preserves the existing canonical harness design and only corrects its Result contract usage.

Design / Roadmap Gate

Affected boundary is the opt-in live canonical test path from _invoke_ouroboros_auto() to AutoHandler.handle() and Result unwrapping. The PR aligns the test with the public Result properties, improves MCP error reporting, and does not alter persistence, runtime state, replay behavior, or handler contracts.

Directional Notes

Maintainer memory emphasized contract correctness and evaluation evidence. I focused review on the Result API boundary and the live canonical invocation path; no blocker is supported by current source evidence.

Test Coverage

  • Reviewed tests/canonical/test_canonical.py, tests/canonical/conftest.py, and src/ouroboros/core/types.py.
  • Confirmed AutoHandler.handle() returns Result[MCPToolResult, MCPServerError], and Result.is_ok, Result.is_err, and Result.error are the correct public API.
  • Attempted focused test run, but local pytest dependency is unavailable in the snapshot environment.

Merge Recommendation

Merge. The patch fixes a real API mismatch in the live canonical harness, and I found no blocking regression in the affected call path.

Review-Metadata:
verdict: APPROVE
head_sha: 1f7dc10
request_id: req_1779699995_3
review_profile: memory-aware-zero-trust-v2
advisory_memory_only: true


Reviewed by ouroboros-agent[bot] via Codex deep analysis

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