Skip to content

Follow-up: permit-bound callers, Python 3.9 import, and docs - #36

Merged
Shards-inc merged 3 commits into
mainfrom
cursor/follow-up-governance-d95f
Oct 20, 2026
Merged

Shards-inc merged 3 commits into
mainfrom
cursor/follow-up-governance-d95f

Conversation

@Shards-inc

Copy link
Copy Markdown
Member

Description

Follow-up to merged PR #35 (7e06e1b). That merge landed the first fail-closed change and left two GitHub Actions jobs red: Python 3.9 could not import AuditLedger, and the docs build rejected links outside the docs tree. The caller, async, and ambiguity work that was still on the branch is included here.

This pull request adds:

  • Python 3.9. load_verified no longer evaluates tuple | list at import. Annotations are postponed.
  • Docs links. docs/README.md points at the repository README and spec with GitHub URLs, so mkdocs build --strict passes.
  • Permit-bound examples and adapters. Examples 03–11, Flask, FastAPI, the SDK client and server, and MCP submit a permit bound to the exact parameters. scripts/smoke.sh runs each example. Adapter tests allow a valid permit and deny a missing or mismatched one.
  • Async kernel. Async classes call the synchronous kernel. AsyncDispatcher.dispatch does not run a tool. StateMachine.reset() does not resume a halted kernel.
  • fail_closed=False. Ambiguous requests are always denied. The flag is not an opt-out.
  • Coverage gate 66%. Measured combined coverage is 66.84% (2,411/3,489 statements, 484/842 branches). The 90% governance branch floor is unchanged.
  • Docs. The cookbook, security notes, whitepaper, quick start, features, and API reference use KernelRequest, boot(KernelConfig), and submit(..., permit_token=permit). RequestBuilder and PolicyBuilder now build those objects. PolicyBuilder.with_custom_rule raises, because JurisdictionPolicy has no custom-rule field.

The audit ledger stays in process memory. It does not fsync. Ed25519, a README rewrite, a PyPI rename, and repository-wide ruff/mypy remain out of scope.

Do not merge. This is for review.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)

Related Issues

Follow-up to #35. No separate issue number.

Invariant Compliance

  • INV-STATE: Single defined state at all times
  • INV-TRANSITION: Only defined transitions occur
  • INV-JURISDICTION: All requests pass jurisdiction checks
  • INV-AUDIT: All transitions produce audit entries
  • INV-HASH-CHAIN: Audit entries are hash-chained
  • INV-FAIL-CLOSED: Ambiguity results in DENY or HALT
  • INV-DETERMINISM: Identical inputs produce identical outputs
  • INV-HALT: Halt is always possible and irrevocable
  • INV-EVIDENCE: Decisions are exportable with verification
  • INV-NO-IMPLICIT-ALLOW: Explicit ALLOW required for execution

Testing

  • Unit tests added/updated
  • All existing tests pass
  • Smoke test passes
  • Manual testing performed

Local, Python 3.12, head of this branch:

  • 223 tests passed
  • Combined coverage 66.84%
  • Governance branch floors all at or above 90%
  • ruff check . --select E,F --ignore E501 passed
  • ./scripts/smoke.sh passed
  • mkdocs build --strict passed

Documentation

  • README updated (if applicable)
  • Docstrings added/updated
  • Specification updated (if applicable)

spec/AUDIT.md already states the in-memory ledger. This change updates the cookbook, security notes, whitepaper, quick start, and API reference. Narrative guides under docs/guides other than the cookbook and quick start, and the operations playbook, still sketch older constructors.

Checklist

  • My code follows the project style guidelines
  • I have performed a self-review of my code
  • I have commented my code where necessary
  • My changes generate no new warnings
Open in Web Open in Cursor 

cursoragent and others added 3 commits October 20, 2026 01:37
Examples, HTTP adapters, and the SDK now issue or forward a permit
bound to the exact call. Ambiguity is always denied, a halted kernel
stays halted across StateMachine.reset, and the async path delegates
to the synchronous kernel. The audit ledger stays in memory and says so.

Co-authored-by: Ayai  <shards-inc@engineer.com>
load_verified annotated a union with the | operator. Python 3.9
evaluates that at import and the 3.9 CI job could not collect tests.

Co-authored-by: Ayai  <shards-inc@engineer.com>
RequestBuilder and PolicyBuilder now emit a KernelRequest and a
JurisdictionPolicy the kernel can boot. The cookbook, security notes,
whitepaper, quick start, and API reference use that path. The coverage
gate is 66%.

Co-authored-by: Ayai  <shards-inc@engineer.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 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-10-20T01:47:36.055909Z f66b788 PR opened
ℹ️ 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.

try:
result = governed_browse(url="https://example.com/final-research")
final_browse = {"url": "https://example.com/final-research"}
result = governed_browse(
try:
result = governed_read(path="/data/final-notes.txt")
final_read = {"path": "/data/final-notes.txt"}
result = governed_read(
HAS_FASTAPI = False

try:
import flask # noqa: F401

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f66b788b2f

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +117 to +120
permits = permits or [None] * len(requests)
receipts = []
for request, permit in zip(requests, permits):
receipts.append(await kernel.submit(request, permit))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve one result for every batched request

When permits is a nonempty list shorter than requests, zip silently stops at the shorter list, so trailing requests are never submitted and the caller receives fewer receipts than requests. Validate that the two lists have equal length (or explicitly pad missing permits) before iterating so a malformed batch cannot silently drop governed work.

Useful? React with 👍 / 👎.

Comment thread kernels/sdk/client.py
Comment on lines +96 to +100
def submit(
self,
request: Request,
permit_token: Optional[PermitToken] = None,
) -> Receipt:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Allow SDK batch callers to supply permits

When a KernelClient or AsyncKernelClient caller batches tool requests that require permits, both submit_batch implementations invoke submit without a permit and expose no way to provide one, so every otherwise authorized tool call is denied with MISSING_PERMIT. Accept a corresponding permit collection and forward each token, as the new single-request API does.

Useful? React with 👍 / 👎.

@Shards-inc
Shards-inc merged commit 3c9bc59 into main Oct 20, 2026
7 checks passed
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