Skip to content

test(sdk/py): salvage first-run contract tests from #591#633

Merged
ojongerius merged 2 commits into
mainfrom
worktree-salvage-py-contract-tests
May 26, 2026
Merged

test(sdk/py): salvage first-run contract tests from #591#633
ojongerius merged 2 commits into
mainfrom
worktree-salvage-py-contract-tests

Conversation

@ojongerius
Copy link
Copy Markdown
Contributor

Summary

Salvages the regression tests from the v0.10.0 first-run audit (closed PR #591) into sdk/py/tests/contracts/ so the contracts they pin survive without the surrounding audit-report markdown.

What's pinned

Test Contract
test_in_process_happy_path README Quick Start (generate → create → sign → hash → verify)
test_two_receipt_chain 2-link chain verify + tamper detection
test_daemon_emitter_roundtrip_against_live_daemon Daemon round-trip (SKIPPED unless AGENTRECEIPTS_SOCKET is set)
test_daemon_emitter_no_daemon_is_silent_drop Current silent-drop on missing daemon
test_top_level_emitter_is_now_a_protocol v0.10.0 breaking rename (Emitter → Protocol)
test_wal_emitter_retains_on_failure_and_replays v0.10.0 WAL retain-replay
test_wal_emitter_cannot_wrap_daemon_emitter runtime_checkable / DaemonEmitter arity footgun (PY-P4)

Tests pinning behaviour under decision

Two of the seven pin behaviour that's currently being reconsidered. Both are flagged in the module docstring so a future maintainer flips them when the decision lands rather than silently keeping a buggy default:

Provenance

PR #591 surfaced these tests inside an audit/ directory alongside a snapshot-dated report and a CI-example workflow. The report and example are not being salvaged (they're rot-prone). The tests are the durable asset and belong in the regular SDK suite.

The other audit findings have been refiled as #630 (closure-1 follow-on, py-readme-daemon-refresh) and #631 (background — "Using Agent Receipts in CI" docs page).

Test plan

  • uv run pytest tests/contracts/ -v — 6 passed, 1 skipped
  • uv run pytest (full sdk/py suite) — 411 passed, 6 skipped
  • uv run ruff check tests/contracts/ — clean
  • uv run ruff format --check tests/contracts/ — clean
  • CI green on remote

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new Python SDK “first-run” contract test suite under sdk/py/tests/contracts/, salvaging the durable regression/UX contracts from closed audit PR #591 so key v0.10.0 behaviors stay pinned in the normal test run.

Changes:

  • Introduces test_first_run.py contract tests covering in-process create/sign/hash/verify, chain verification/tamper detection, daemon emitter round-trip (opt-in via AGENTRECEIPTS_SOCKET), silent-drop behavior, top-level Emitter Protocol behavior, and WAL retain/replay semantics.
  • Adds the tests/contracts package initializer to integrate the suite into pytest discovery.

Reviewed changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated 1 comment.

File Description
sdk/py/tests/contracts/test_first_run.py Adds first-run contract tests pinning day-one SDK behaviors (in-process flow, daemon emitter contracts, and WAL semantics).
sdk/py/tests/contracts/init.py Creates the contracts test package for pytest discovery/organization.

Comment thread sdk/py/tests/contracts/test_first_run.py
ojongerius added a commit that referenced this pull request May 26, 2026
Drops the `_is_protocol` attribute check and the exact TypeError message
match in `test_top_level_emitter_is_now_a_protocol`. Both are `typing`
implementation details that can drift across Python versions. The
behavioural contract — that instantiating `Emitter` raises TypeError —
is what matters from the user's perspective and is what the test now
pins.

Addresses Copilot feedback on #633.
@ojongerius ojongerius requested a review from Copilot May 26, 2026 06:26
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 2 changed files in this pull request and generated no new comments.

Salvages the regression tests from the v0.10.0 first-run audit (closed
PR #591) into the sdk/py suite so the contracts they pin survive without
the surrounding audit-report markdown.

Pinned contracts:
- In-process happy path (README Quick Start)
- 2-link chain verify + tamper detection
- Top-level `Emitter` is a Protocol (v0.10.0 breaking rename)
- `WalEmitter` retains on failure and replays (v0.10.0 WAL fix)
- Live-daemon round-trip (skipped unless AGENTRECEIPTS_SOCKET is set)

Two tests pin behaviour that is currently under decision and are flagged
in module docstring to be flipped when the decision lands rather than
silently kept:

- silent-drop on missing daemon (#599 emit-failure-contract)
- runtime_checkable / DaemonEmitter arity footgun (PY-P4)
Drops the `_is_protocol` attribute check and the exact TypeError message
match in `test_top_level_emitter_is_now_a_protocol`. Both are `typing`
implementation details that can drift across Python versions. The
behavioural contract — that instantiating `Emitter` raises TypeError —
is what matters from the user's perspective and is what the test now
pins.

Addresses Copilot feedback on #633.
@ojongerius ojongerius force-pushed the worktree-salvage-py-contract-tests branch from 501bdf6 to 3fea55e Compare May 26, 2026 06:37
@ojongerius ojongerius requested a review from Copilot May 26, 2026 06:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 2 changed files in this pull request and generated no new comments.

@ojongerius ojongerius merged commit 0140032 into main May 26, 2026
14 checks passed
@ojongerius ojongerius deleted the worktree-salvage-py-contract-tests branch May 26, 2026 06:48
ojongerius added a commit that referenced this pull request May 26, 2026
Mark closure-1 nodes shipped (#621/#623/#624/#625/#628), add
daemon-setup-stale-api and py-readme-daemon-refresh nodes, record
#632/#633/#634, note #592 trusted-publishing blocker, refresh
Next farmable section.
ojongerius added a commit that referenced this pull request May 26, 2026
* chore: remove committed binary and expand .gitignore

Removes the accidentally committed agent-receipts Mach-O binary and
adds /agent-receipts, /bin/, and /daemon/bin/ to .gitignore so built
binaries cannot be committed again.

* docs(ops): update current.md for 2026-05-26

Mark closure-1 nodes shipped (#621/#623/#624/#625/#628), add
daemon-setup-stale-api and py-readme-daemon-refresh nodes, record
#632/#633/#634, note #592 trusted-publishing blocker, refresh
Next farmable section.
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