Skip to content

fix(build): Gate the cold build on a frozen wanted-source receipt - #5379

Merged
Sinity merged 1 commit into
masterfrom
fix/coldbuild-preflight
Sep 22, 2026
Merged

Sinity merged 1 commit into
masterfrom
fix/coldbuild-preflight

Conversation

@Sinity

@Sinity Sinity commented Sep 22, 2026

Copy link
Copy Markdown
Owner

Summary

polylogue-co2iz AC3 requires the final rebuild preflight to accept only a complete, valid receipt and never silently fresh-walk ambient source roots. The check existed; the build driver never called it.

Problem (evidence at 158d1363e)

require_rebuild_preflight (maintenance/source_manifest_continuity.py:664, real entry preflight_rebuild at :641) has owned this since #5304. Its complete production caller set was one CLI command — cli/commands/maintenance/_wanted_sources.py:103,138.

ColdBuildGeneration.begin — the actual final-build driver — called only require_candidate_capacity (sources/live/cold_build.py:120). So a cold build could start with no frozen denominator at all, and the rebuild's conservation proof would have nothing fixed to reconcile against.

Solution

Authorization runs before allocation and before the capacity walk, because its refusal means "this build must not happen" rather than "not here, not now".

Like the capacity preflight, it is not conditioned on operator intent — the docstring at cold_build.py:97-102 already settles that: the build engages automatically whenever the active generation is empty, which is exactly the unattended whole-archive case that must not run unauthorized.

It is conditioned on a denominator existing at all, which is a different question. build_wanted_source_receipt itself refuses an empty denominator, so requiring a receipt where no source is declared would make every live-capture-only archive permanently unbuildable. That bootstrap path emits daemon.cold_build.wanted_sources_undeclared and is pinned by a test — declared, not silent. Once a receipt is published it validates unconditionally even if the roots were later undeclared: a frozen denominator the current configuration no longer matches is a typed refusal, never a downgrade.

wanted_source_receipt_is_published exists to separate "there is no receipt" from "the receipt is tampered", which load_wanted_source_receipt reports through one exception type. No branch falls back to walking source roots fresh.

Verification

Exit codes read directly, not through a filter.

devtools test tests/unit/sources/test_cold_build_generation.py \
              tests/unit/maintenance/test_source_manifest_continuity.py
  -> PASSED exit=0
  receipt .cache/verify/runs/20260922T010507Z-focused-test-224388-d3e0f78c/run.json

devtools verify --quick   -> exit 0, all 25 gates ok (test-collection 100.0s)
devtools gate schema-closure -> ok, 557 members, 0 added, 0 removed

Four tests: refuse-unfrozen, refuse-tampered, authorize-valid, and the undeclared bootstrap path — the last pinning the opposite direction so "refuse everything" fails.

Schema identity

cold_build.py and source_manifest_continuity.py are both closure IN, so the derived index identity moves d5e285b3… → 7cb86235…; ops is unchanged at 86866235…. Closure membership is unchanged (557 both sides), so no baseline update is required. This must land before a fresh rebuild starts, never during one.

Residual

The live host currently declares no source roots (resolve_runtime_config().source_paths.explicit == ()), so on that archive this guard takes the declared bootstrap path. Declaring the roots and freezing the receipt against the fresh root is an operator action, and co2iz stays open for it — this PR closes AC3's code half only.

🤖 Generated with Claude Code

https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy

polylogue-co2iz AC3 requires the final rebuild preflight to accept only a
complete, valid receipt and never silently fresh-walk ambient source roots.
`require_rebuild_preflight` has owned that check since #5304, but its only
production caller was the operator CLI (cli/commands/maintenance/_wanted_sources.py).
`ColdBuildGeneration.begin` -- the actual final-build driver -- called only
`require_candidate_capacity`, so a cold build could start with no frozen
denominator at all.

Authorization now runs before allocation and before the capacity walk, because
its refusal means "this build must not happen" rather than "not here, not now".
Like the capacity preflight it is not conditioned on operator intent: the build
engages automatically whenever the active generation is empty, which is exactly
the unattended whole-archive case that must not run unauthorized.

It is conditioned on a denominator existing at all, which is a different
question. `build_wanted_source_receipt` itself refuses an empty denominator, so
requiring a receipt where no source is declared would make every
live-capture-only archive permanently unbuildable. That bootstrap path emits
`daemon.cold_build.wanted_sources_undeclared` and is pinned by a test, so it is
declared rather than silent. Once a receipt *is* published it validates
unconditionally, even if the roots were later undeclared: a frozen denominator
the current configuration no longer matches is a typed refusal, never a
downgrade. `wanted_source_receipt_is_published` exists to separate "there is no
receipt" from "the receipt is tampered", which `load_wanted_source_receipt`
reports through one exception type.

The refusal names both the defect and the single command that produces a
receipt. No branch falls back to walking source roots fresh.

Verification (exit codes read directly, not through a filter):
  devtools test tests/unit/sources/test_cold_build_generation.py \
    tests/unit/maintenance/test_source_manifest_continuity.py
    -> PASSED exit=0, receipt .cache/verify/runs/20260922T010507Z-focused-test-224388-d3e0f78c/run.json
  devtools gate schema-closure -> ok, 557 members, none added or removed

Schema identity: cold_build.py and source_manifest_continuity.py are both
closure IN, so the derived index identity moves d5e285b3.. -> 7cb86235..; ops is
unchanged at 86866235... Closure *membership* is unchanged, so no baseline
update is required. This must land before a fresh rebuild starts, never during
one.

Residual, not addressed here: the live host currently declares no source roots
(`resolve_runtime_config().source_paths.explicit == ()`), so on that archive this
guard takes the declared bootstrap path. Declaring the roots and freezing the
receipt against the fresh root is an operator action, and co2iz stays open for it.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy
@coderabbitai

coderabbitai Bot commented Sep 22, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 26 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: cb4db1fb-2c7f-4a93-83d5-a432d0228af0

📥 Commits

Reviewing files that changed from the base of the PR and between 5fe621a and d52028a.

📒 Files selected for processing (3)
  • polylogue/maintenance/source_manifest_continuity.py
  • polylogue/sources/live/cold_build.py
  • tests/unit/sources/test_cold_build_generation.py

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 22, 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-09-22T01:19:18.446497Z d52028a PR opened
🔒 Security Review ✅ Completed 2026-09-22T01:18:11.649492Z d52028a 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.

@Sinity
Sinity enabled auto-merge (squash) September 22, 2026 01:11

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

ℹ️ 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 polylogue/sources/live/cold_build.py Resolved
@Sinity
Sinity merged commit b713019 into master Sep 22, 2026
3 checks passed
@Sinity
Sinity deleted the fix/coldbuild-preflight branch September 22, 2026 01:22
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