Skip to content

Integrate raw trusted weekly period bundle verifier - #34

Closed
Pigbibi wants to merge 2 commits into
mainfrom
codex/pert-weekly-trusted-period-bundle-a1
Closed

Integrate raw trusted weekly period bundle verifier#34
Pigbibi wants to merge 2 commits into
mainfrom
codex/pert-weekly-trusted-period-bundle-a1

Conversation

@Pigbibi

@Pigbibi Pigbibi commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Scope

Fresh PR-A1 integration from merged raw identity A0 at cf0dcaf6f541d9b04c6f3a319aeb546dc681f725.

  • pure raw-byte period lock/source snapshot/bundle manifest builder and verifier;
  • bounded member parsing, exact canonical round-trip, duplicate/type/size checks;
  • fixed repository/workflow path/ref and explicit reviewed SHA binding;
  • run/source-attempt and artifact name/id/digest/retention binding;
  • manifest structural validation before reconstructed-byte comparison;
  • no Python object identity/frozen dataclass/singleton/capability/registry trust.

Non-scope

No workflow, permissions, Actions acquisition, artifact upload/download, rerun,
producer, QAR, Pages, legacy, migration, or A1B integration. Frozen PR #31 and
PR #32 are not reused.

Verification

  • focused A1 tests: 16 passed
  • full python3 -m pytest -q: 128 passed
  • uv sync --locked --extra test: passed
  • locked uv run --locked pytest -q: 128 passed
  • compileall: passed
  • diff-check: passed
  • ruff: unavailable

A privileged workflow remains a later boundary and is not part of this PR.

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

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

🤖 Codex PR Review

🚫 Merge blocked: 1 serious issue(s) found in high-risk files

🚫 Blocking Issues

These issues must be fixed before this PR can be merged:

1. 🟠 [HIGH] Logic in src/political_event_tracking_research/trusted_period_bundle_raw.py

_snapshot() rejects any source_artifacts list longer than 64 items, and the surrounding snapshot normalization also adds extra per-string/per-object limits that weekly_period_lock does not enforce. That means a canonical lock can still serialize and parse successfully upstream, but build_period_bundle() / verify_period_bundle() will fail on the matching snapshot once the producer emits more than 64 source artifacts (or other values that only violate these bundle-only caps), even when every raw member is still within the documented 256 KiB byte bound. This is a real API-compatibility break between the lock contract and the new bundle verifier. (line 211)

Suggestion: Either remove the bundle-only structural caps and rely on the existing raw-byte size limit, or enforce the exact same limits in weekly_period_lock and the producer so the bundle layer cannot reject canonical locks that upstream already considers valid.


Review by Codex PR Review bot • PR

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

ℹ️ 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 +426 to +427
if values["snapshot_bytes"] != expected_snapshot_bytes or actual_snapshot != expected_snapshot:
raise _error("bundle_snapshot_mismatch")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Reconstruct the expected snapshot in verification

When verify_period_bundle() is called on a bundle assembled outside build_period_bundle(), this check only confirms that the snapshot bytes match the caller-provided expected snapshot; it never re-derives _expected_snapshot(expected_lock, expected_identity["reviewed_workflow_sha"]) the way the builder does. A crafted bundle can therefore use a lock and artifact for run A while the canonical snapshot internally names a different run/provenance/workflow SHA, and the manifest can still be reconstructed with the mismatched snapshot hash, so the verifier accepts a bundle that is not actually bound to the lock or identity.

Useful? React with 👍 / 👎.

Comment on lines +238 to +239
if any(type(key) is not str for key, _ in items):
raise _error("bundle_artifact_invalid")

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 Sanitize malformed artifact item shapes

When artifact is a malformed Mapping whose items() yields non-pair entries, this unpacking raises Python's raw ValueError before the later dict(items) try/except can sanitize it. That affects both build_period_bundle() and verify_period_bundle() inputs at the trust boundary, so malformed artifact mappings bypass the promised TrustedPeriodBundleError failure mode instead of failing closed with a stable code.

Useful? React with 👍 / 👎.

Comment on lines +207 to +208
if snapshot["source_attempt"] != 1:
raise _error("bundle_snapshot_attempt_invalid")

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 Require an integer snapshot attempt

For caller-supplied snapshot bytes, this equality accepts JSON values such as true or 1.0 because they compare equal to 1 in Python, and the later canonicalization preserves those non-integer values. That means verify_period_bundle() can return a bundle whose snapshot violates the contract's exact integer source_attempt type; this should use the same exact-int validation applied to the lock and manifest before checking the value.

Useful? React with 👍 / 👎.

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

Pigbibi commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

Concentrated closure applied at e2cfcc3f3c3ea51fcaeb3a87bab84d08c357a554.

  • Expected snapshot bytes are fully parsed and revalidated against the period lock, producer SHA, workflow SHA, run/attempt, source metadata, and artifact list before equality checks.
  • Mapping shapes are checked before .items()/conversion; expected malformed inputs produce sanitized bundle errors while runtime/system exceptions propagate.
  • source_attempt now requires exact built-in int == 1 across snapshot and manifest paths.
  • Added semantic snapshot forgery, lock/identity mismatch, malformed mapping/item, and bool/float/unsafe attempt regressions.

Pure A1 scope remains unchanged: no workflow, permissions, Actions, upload/download, rerun, producer, QAR, Pages, legacy, or A1B integration.

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

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

items = list(bundle.items())
except (AttributeError, TypeError, ValueError, UnicodeError, OverflowError, RecursionError):
raise _error("bundle_shape_invalid") from None
if len(items) != len(_BUNDLE_KEYS) or any(type(key) is not str for key, _ in items):

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 Sanitize malformed bundle item shapes

When an untrusted Mapping returns a non-pair entry from items(), list(bundle.items()) succeeds but this generator unpacking raises Python's raw ValueError before the later dict(items) try/except can sanitize it. For example, a bundle item shaped like ('artifact', value, 'extra') bypasses the documented TrustedPeriodBundleError failure mode at the verify_period_bundle() trust boundary instead of failing closed with a stable code.

Useful? React with 👍 / 👎.

@Pigbibi

Pigbibi commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

PERMANENT_FREEZE/HUMAN_REQUIRED per stop rule. Preserving branch/worktree/commits/comments/threads/checks/tests/evidence; no further code action.

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