Skip to content

feat: add single-use research mandate guard - #299

Merged
Pigbibi merged 1 commit into
mainfrom
codex/qsl-p3-soxl-stage-a-qpk-single-use-authority-guard-20260806
Aug 5, 2026
Merged

feat: add single-use research mandate guard#299
Pigbibi merged 1 commit into
mainfrom
codex/qsl-p3-soxl-stage-a-qpk-single-use-authority-guard-20260806

Conversation

@Pigbibi

@Pigbibi Pigbibi commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add a dedicated two-hour research mandate with a fresh nonce and frozen candidate/mandate/config/input/authority identity
  • atomically consume it once through a private SQLite state file and persist terminal invalidation across restart/replay
  • emit a deterministic sanitized consumption receipt without nonce, raw identities, credential/provider payloads, or market data

Boundaries

  • offline/synthetic tests only; no provider/session/data acquisition
  • no production dependency, generic persistence/locking framework, RiskEngine, broker/order/runtime, workflow, manifest, or downstream pin change

Tests

  • tests-first RED: module absent on exact base
  • focused: 20 passed
  • full: 920 passed, 1 skipped, 80 subtests passed
  • Ruff, compileall, git diff --check, exact-two-path scope and dependency-file gates passed

Co-Authored-By: Codex <noreply@openai.com>
@Pigbibi
Pigbibi merged commit cca709a into main Aug 5, 2026
1 check passed
@Pigbibi
Pigbibi deleted the codex/qsl-p3-soxl-stage-a-qpk-single-use-authority-guard-20260806 branch August 5, 2026 17:01

@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: b3d4ca32b8

ℹ️ 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 +602 to +606
descriptor = os.open(
self._database,
os.O_CREAT | os.O_EXCL | os.O_WRONLY,
0o600,
)

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 Handle first-use create races

When multiple valid issuers hit a fresh authority DB concurrently, the loser of the O_EXCL create gets FileExistsError here and the following except OSError denies it instead of reopening/validating the newly-created store. A second process can also connect while the first has only created the empty file and fail validation, so valid first-start issuance nondeterministically fails; retry/open the existing DB after an exclusive-create race or initialize under a lock.

Useful? React with 👍 / 👎.

Comment on lines +672 to +675
columns = tuple(
row[1] for row in connection.execute("PRAGMA table_info(mandates)")
)
if columns != _ROW_FIELDS:

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 Reject stores with missing constraints

If the authority opens an existing SQLite file that has the same column order and metadata but omits the UNIQUE/CHECK/PRIMARY KEY constraints from _CREATE_SCHEMA, this validation still passes. In that context issue() can insert multiple rows with the same mandate_id because the code relies on the database constraint rather than rechecking it, so a damaged or spoofed store does not fail closed; validate the actual schema/indexes before accepting an existing store.

Useful? React with 👍 / 👎.

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.

1 participant