-
Notifications
You must be signed in to change notification settings - Fork 16
feat(constation): production Lium image-attestation wire #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
echobt
merged 9 commits into
BaseIntelligence:main
from
alpha1122x:feat/prism-constation-production-wire
Jul 26, 2026
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
fb32380
feat(compute): add image-attestation constation libraries
echobt d24aaa8
feat(db): add allowlist and attestation nonce tables
echobt f2889c3
feat(master): wire durable constation hosts and bundle forward
echobt ef5a1ae
feat(prism): host attestation routes and production constation gate
echobt 7889314
test(constation): cover allowlist nonce routes and scoring gate
echobt ce6ffe7
chore(scripts): add offline lium attestation e2e harnesses
echobt 8e1a825
style(constation): fix ruff E501 and apply ruff format
echobt 928edec
fix(constation): satisfy mypy and package-scoped prism ruff
echobt 5a7fd83
fix(tests): contain process-global leaks from the new constation tests
echobt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| """BASE-produced image digest allowlist + revocation denylists. | ||
|
|
||
| Adds durable storage for mechanism 4 (digest allowlist) of prism-lium image | ||
| attestation. Lookup rules live in ``base.compute.digest_allowlist``; these | ||
| tables only persist registered bindings and denylist entries. | ||
|
|
||
| Revision ID: 0017_digest_allowlist | ||
| Revises: 0016_watcher_state | ||
| Create Date: 2026-07-26 00:00:00.000000 | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from collections.abc import Sequence | ||
|
|
||
| import sqlalchemy as sa | ||
|
|
||
| from alembic import op | ||
|
|
||
| revision: str = "0017_digest_allowlist" | ||
| down_revision: str | None = "0016_watcher_state" | ||
| branch_labels: str | Sequence[str] | None = None | ||
| depends_on: str | Sequence[str] | None = None | ||
|
|
||
|
|
||
| def upgrade() -> None: | ||
| """Apply the migration.""" | ||
|
|
||
| op.create_table( | ||
| "image_digest_allowlist", | ||
| sa.Column("id", sa.Uuid(as_uuid=True), nullable=False), | ||
| sa.Column("commit_sha", sa.Text(), nullable=False), | ||
| sa.Column("tree_sha", sa.Text(), nullable=False), | ||
| sa.Column("variant", sa.Text(), nullable=False), | ||
| sa.Column("digest", sa.Text(), nullable=False), | ||
| sa.Column( | ||
| "created_at", | ||
| sa.DateTime(timezone=True), | ||
| server_default=sa.func.now(), | ||
| nullable=False, | ||
| ), | ||
| sa.Column( | ||
| "updated_at", | ||
| sa.DateTime(timezone=True), | ||
| server_default=sa.func.now(), | ||
| nullable=False, | ||
| ), | ||
| sa.PrimaryKeyConstraint("id", name=op.f("pk_image_digest_allowlist")), | ||
| sa.UniqueConstraint("digest", name="uq_image_digest_allowlist_digest"), | ||
| sa.UniqueConstraint( | ||
| "commit_sha", | ||
| "tree_sha", | ||
| "variant", | ||
| name="uq_image_digest_allowlist_commit_tree_variant", | ||
| ), | ||
| ) | ||
| op.create_index( | ||
| "ix_image_digest_allowlist_commit_sha", | ||
| "image_digest_allowlist", | ||
| ["commit_sha"], | ||
| unique=False, | ||
| ) | ||
| op.create_index( | ||
| "ix_image_digest_allowlist_variant", | ||
| "image_digest_allowlist", | ||
| ["variant"], | ||
| unique=False, | ||
| ) | ||
|
|
||
| op.create_table( | ||
| "denied_image_digests", | ||
| sa.Column("digest", sa.Text(), nullable=False), | ||
| sa.Column("reason", sa.Text(), nullable=True), | ||
| sa.Column( | ||
| "created_at", | ||
| sa.DateTime(timezone=True), | ||
| server_default=sa.func.now(), | ||
| nullable=False, | ||
| ), | ||
| sa.PrimaryKeyConstraint("digest", name=op.f("pk_denied_image_digests")), | ||
| ) | ||
|
|
||
| op.create_table( | ||
| "denied_image_commits", | ||
| sa.Column("commit_sha", sa.Text(), nullable=False), | ||
| sa.Column("reason", sa.Text(), nullable=True), | ||
| sa.Column( | ||
| "created_at", | ||
| sa.DateTime(timezone=True), | ||
| server_default=sa.func.now(), | ||
| nullable=False, | ||
| ), | ||
| sa.PrimaryKeyConstraint("commit_sha", name=op.f("pk_denied_image_commits")), | ||
| ) | ||
|
|
||
|
|
||
| def downgrade() -> None: | ||
| """Revert the migration.""" | ||
|
|
||
| op.drop_table("denied_image_commits") | ||
| op.drop_table("denied_image_digests") | ||
| op.drop_index( | ||
| "ix_image_digest_allowlist_variant", | ||
| table_name="image_digest_allowlist", | ||
| ) | ||
| op.drop_index( | ||
| "ix_image_digest_allowlist_commit_sha", | ||
| table_name="image_digest_allowlist", | ||
| ) | ||
| op.drop_table("image_digest_allowlist") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| """BASE-issued single-use attestation nonces for prism-lium constation. | ||
|
|
||
| Adds durable storage for mechanism 1 (nonce-bound attestation). Issue/consume | ||
| rules live in ``base.compute.attestation_nonce``; this table only persists | ||
| issued nonces and their consume timestamps (BASE clocks only). | ||
|
|
||
| Revision ID: 0018_attestation_nonces | ||
| Revises: 0017_digest_allowlist | ||
| Create Date: 2026-07-26 00:00:00.000000 | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from collections.abc import Sequence | ||
|
|
||
| import sqlalchemy as sa | ||
|
|
||
| from alembic import op | ||
|
|
||
| revision: str = "0018_attestation_nonces" | ||
| down_revision: str | None = "0017_digest_allowlist" | ||
| branch_labels: str | Sequence[str] | None = None | ||
| depends_on: str | Sequence[str] | None = None | ||
|
|
||
|
|
||
| def upgrade() -> None: | ||
| """Apply the migration.""" | ||
|
|
||
| op.create_table( | ||
| "attestation_nonces", | ||
| sa.Column("nonce", sa.Text(), nullable=False), | ||
| sa.Column("work_unit_id", sa.Text(), nullable=False), | ||
| sa.Column("miner_hotkey", sa.Text(), nullable=False), | ||
| sa.Column("pod_id", sa.Text(), nullable=False), | ||
| sa.Column("issued_at", sa.DateTime(timezone=True), nullable=False), | ||
| sa.Column("expires_at", sa.DateTime(timezone=True), nullable=False), | ||
| sa.Column("consumed_at", sa.DateTime(timezone=True), nullable=True), | ||
| sa.PrimaryKeyConstraint("nonce", name=op.f("pk_attestation_nonces")), | ||
| ) | ||
| op.create_index( | ||
| "ix_attestation_nonces_work_unit_id", | ||
| "attestation_nonces", | ||
| ["work_unit_id"], | ||
| unique=False, | ||
| ) | ||
| op.create_index( | ||
| "ix_attestation_nonces_miner_hotkey", | ||
| "attestation_nonces", | ||
| ["miner_hotkey"], | ||
| unique=False, | ||
| ) | ||
| op.create_index( | ||
| "ix_attestation_nonces_expires_at", | ||
| "attestation_nonces", | ||
| ["expires_at"], | ||
| unique=False, | ||
| ) | ||
|
|
||
|
|
||
| def downgrade() -> None: | ||
| """Revert the migration.""" | ||
|
|
||
| op.drop_index( | ||
| "ix_attestation_nonces_expires_at", | ||
| table_name="attestation_nonces", | ||
| ) | ||
| op.drop_index( | ||
| "ix_attestation_nonces_miner_hotkey", | ||
| table_name="attestation_nonces", | ||
| ) | ||
| op.drop_index( | ||
| "ix_attestation_nonces_work_unit_id", | ||
| table_name="attestation_nonces", | ||
| ) | ||
| op.drop_table("attestation_nonces") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
Test-only bundle injection lives in production code guarded solely by a settings flag.
_test_constation_kwargsfabricates an always-valid constation bundle wheneverallow_insecure_signaturesis true. A single misconfiguration in a deployed environment silently disables the entire P1 fail-closed gate. Consider asserting a non-production marker as well (e.g. also require a dedicated test-mode setting), or moving this seam into the test conftest, which already provides_auto_constation_for_legacy_ingestion.🤖 Prompt for AI Agents