Skip to content

test: prove operator CLI public-key execution and replay denial across killed process restart - #76

Merged
Shards-inc merged 4 commits into
mainfrom
test/operator-process-restart-replay-20261102
Nov 2, 2026
Merged

Shards-inc merged 4 commits into
mainfrom
test/operator-process-restart-replay-20261102

Conversation

@Shards-inc

Copy link
Copy Markdown
Member

Process-boundary acceptance proof for #69 / #63

Adds real subprocess isolation using Python multiprocessing spawn, invoking the actual shards-kernel serve --config CLI parser in a fresh interpreter. The test issuer holds a freshly generated Ed25519 private key in the parent test interpreter; only public verification material enters the service config. The secret bearer is supplied via environment rather than committed source.

Assertion sequence

  1. The CLI serves /health on fixed loopback, using validated operator config.
  2. Unauthenticated /submit → HTTP 401.
  3. Attempt to spoof a different agent despite correct bearer → HTTP 403.
  4. Signed v2 permit from parent issuer → HTTP 200 receipt ALLOW, tool returns one-time.
  5. Exported audit ledger has a verified root hash.
  6. Forcefully terminate service process (no graceful flush hook).
  7. Spawn a new interpreter with the same SQLite audit path and public config.
  8. Recovered audit root equals pre-crash root; replay of the same signed permit returns DENY/REPLAY_DETECTED.

Requires Python 3.9–3.12 CI, all static/security checks, coverage and docs to pass.

Explicit limitations

The side effect is built-in echo, not a non-idempotent external action. This does not establish distributed nonce transactions, secure remote agent credentials, independent protected issuer deployment, wallet safety, signed configuration or multi-node recovery. All relevant P0 issues remain open.

status, data = _request(base + "/health")
if status == 200 and data["status"] == "healthy":
return process
except (OSError, ValueError):

@codacy-production codacy-production Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

⚠️ Resolve issues before merging

Two test assertions currently weaken the evidence this PR provides. The process restart should use an unconditional kill to demonstrate recovery after abrupt termination, and the audit-root check should validate that the exported root is present and valid rather than only comparing two values. The coverage report is empty, so it does not independently establish production-path coverage.

Test suggestions

  • Start the actual CLI in a spawned process and wait for a healthy loopback HTTP service.
  • Reject an unauthenticated submit request.
  • Reject an authenticated request with a spoofed actor.
  • Accept a valid signed permit and execute the configured echo tool.
  • Preserve the audit root across forced termination and restart.
  • Reject reuse of the original signed permit as a replay after restart.
  • Verify that the service configuration contains only public issuer key material.

TIP Improve review quality by adding custom instructions
TIP How was this review? Give us feedback


def _terminate(process):
if process.is_alive():
process.terminate()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 MEDIUM RISK

Replace the normal terminate() path used by this test with an unconditional hard kill (for example, process.kill()), so the ledger is reopened after an actual abrupt process death rather than a potentially graceful shutdown.

TIP React 👍 if this review is right, or reply with what's wrong and how it could be better to help improve the reviewer.

restarted = _launch(config_path, base)
try:
status, restored = _request(base + "/evidence", bearer=bearer)
assert status == 200

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 MEDIUM RISK

Suggestion: Assert that the exported root hash is present and valid before terminating the service, rather than relying solely on equality after restart.

TIP React 👍 if this review is right, or reply with what's wrong and how it could be better to help improve the reviewer.

@Shards-inc
Shards-inc marked this pull request as ready for review November 2, 2026 01:09
@Shards-inc
Shards-inc merged commit 157d97c into main Nov 2, 2026
17 checks passed
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-02T01:09:54.157636Z 8b145ad Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 21 complexity · 0 duplication

Metric Results
Complexity 21
Duplication 0

View in Codacy

AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant