Skip to content

feat: add verified TQQQ snapshot package boundary - #217

Closed
Pigbibi wants to merge 3 commits into
mainfrom
codex/qsl-p2-tqqq-trust-boundary-v2-20260729
Closed

feat: add verified TQQQ snapshot package boundary#217
Pigbibi wants to merge 3 commits into
mainfrom
codex/qsl-p2-tqqq-trust-boundary-v2-20260729

Conversation

@Pigbibi

@Pigbibi Pigbibi commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add strict JSON codec and verified receipt/calendar package loader
  • preserve existing TQQQ R1 validation and weekend rejection
  • add focused trust-boundary tests

Validation

  • PYTHONPATH=src python3 -m pytest -q tests/test_tqqq_r1_snapshot.py tests/test_tqqq_trusted_snapshot_package.py
  • python3 -m ruff check ...
  • python3 -m compileall -q src

Scope is limited to the two production/test files; no provider, replay, or live execution.

Co-Authored-By: Codex <noreply@openai.com>

@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: 81cd163421

ℹ️ 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 thread src/us_equity_snapshot_pipelines/tqqq_trusted_snapshot_package.py
Comment thread src/us_equity_snapshot_pipelines/tqqq_trusted_snapshot_package.py Outdated
Comment thread src/us_equity_snapshot_pipelines/tqqq_trusted_snapshot_package.py
Comment thread src/us_equity_snapshot_pipelines/tqqq_trusted_snapshot_package.py Outdated
Pigbibi and others added 2 commits July 29, 2026 17:20
Co-Authored-By: Codex <noreply@openai.com>
Co-Authored-By: Codex <noreply@openai.com>

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

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

except tqqq_r1_snapshot.SnapshotValidationError as exc:
raise TrustedSnapshotPackageError("invalid verified snapshot") from exc
try:
resolved_snapshot_dir = verified_snapshot.output_dir.resolve(strict=True)

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 Prevent snapshot replacement after verification

When the snapshot directory is caller-writable, another process can rename it and replace it with a symlink after verify_tqqq_r1_snapshot returns but before this resolution. resolve(strict=True) then follows the replacement, and the new target receives only the weak _snapshot_sessions check rather than full snapshot verification, so an arbitrary directory containing a prices.csv with the bound session can be returned as trusted. Verification, session extraction, and the returned reference need to operate on the same stable directory/inode.

Useful? React with 👍 / 👎.

parse_constant=_reject_constant,
parse_float=_parse_finite_float,
)
except (UnicodeDecodeError, json.JSONDecodeError, TrustedSnapshotPackageError) as exc:

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 Catch oversized integer parse failures

On supported Python versions with the default integer digit limit, an evidence payload containing an integer literal longer than the limit makes json.loads raise a plain ValueError, not JSONDecodeError. Because this handler omits ValueError, malformed caller-controlled package, receipt, or calendar evidence can escape the loader as a raw exception instead of the documented TrustedSnapshotPackageError; catch and normalize this parse failure as well.

Useful? React with 👍 / 👎.


def _read_evidence(path: str | Path, name: str) -> tuple[object, str]:
payload = _read_regular(path, name)
return read_strict_json(payload, name), hashlib.sha256(payload).hexdigest()

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 Authenticate evidence before decoding it

When local evidence files are attacker-writable, a substituted package, receipt, or calendar can contain arbitrarily expensive or malformed JSON. Tuple expressions are evaluated left-to-right, so this function parses the payload before computing its digest, and the loader parses all three files before comparing the package and receipt trust anchors; unauthenticated bytes can therefore consume parser resources or raise an exception before the inevitable hash mismatch. Hash each raw buffer first, validate the external package/receipt anchors and the calendar digest from the authenticated manifest, and only then decode those same bytes.

Useful? React with 👍 / 👎.

@Pigbibi

Pigbibi commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

P2 V2 final settlement: final Codex review was performed on immutable head ea2bddba357ffcfd4ca868efc943483f7f2097c7; required CI test was SUCCESS. The phase is fail-closed and will be closed unmerged because final review identified three new unresolved P2 findings. No post-final patch, thread mutation, rerun, or merge will follow.

@Pigbibi Pigbibi closed this Jul 29, 2026
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