Skip to content

Bound first-pilot infrastructure retirement accounting - #1365

Merged
brettheap merged 6 commits into
mainfrom
change/bound-infrastructure-retirement-accounting
Nov 23, 2026
Merged

brettheap merged 6 commits into
mainfrom
change/bound-infrastructure-retirement-accounting

Conversation

@brettheap

@brettheap brettheap commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

P07's unchanged provider path exhausts ordinary private12 before completing its second resource, while namespace I/O is unmetered. This source-only amendment selects a dedicated finite infrastructure policy for the first codeXfactory pilot and preserves every existing proof/readback limit.

Paired handoff: opensoft/openXwallet#104
Reviewed pair: factory 89dbe6e6640361c36321968725932058aa802e2b with wallet ea7a46206413ba5392734fa67def7dcef6861835.

The inventory selects 14 ephemeral resources and 16 dependency edges, including three role-specific NSGs. Registration, cleanup and independently current observation have disjoint pools. Whole maxima are 1088 private / 208 ARM / 768 namespace / 192 journal calls and 16 MiB application bytes; the conservative model is 927 / 168 / 447 / 122. Both facade RPCs and physical backend I/O are charged. Original intervals are 30 / 300 / 60 seconds, each call <=10 seconds, clipped to original approvals/expiry. Old proof Decision/private12/ARM24 and all old routes retain their limits.

The final policy requires a durable exclusive ownership switch before external cleanup, ambiguous-handoff refusal, original registration/cleanup ownership, a separate original observer owner, exact cleanup-claim/anchor binding, serialized admission/debits and read-only resolution of the permanent registration slot. Mutation-owner loss burns its remainder without transfer/restart. The later additive infrastructure account is explicit; ordinary ReadBudget is not enlarged.

Validation:

  • Complete generated 280-row corpus ledger names actual PR Bound first-pilot infrastructure retirement accounting #1365; local code-surface and ledger checks pass. Earlier pinned whole-corpus OpenSpec checks pass; replacement hosted checks verify final source.
  • Nonproduct helper reproduces the exact inventory offline. Twelve substantive reproduction/arithmetic/graph/cap/tamper tests pass with 89% local branch coverage. No workflow, exclusion, pin, quality threshold or runtime limit changed.
  • Optional actual baseline-parser repetition verifies all five recorded source hashes before project imports and reproduces the same inventory. Five complete canonical synthetic records fit16KiB (largest9,855bytes). Default offline reproduction checks recorded fixture bytes and arithmetic; neither is service authentication or a P07 runtime positive.
  • Nine local Codex expert roles plus coordinator clear this exact pair after resolving ownership/accounting findings. Azure-order feedback was checked against the actual prerequisite-absence reader and correctly leaves the graph unchanged.
  • Factory hosted qualification passed: https://github.com/opensoft/openXfactory/actions/runs/45227111903 — 10,893 passed plus874 subtests; the existing6 skips/338 postgres deselections are retained, zero failures/errors. The separate043 source suite passed958 cases. All PR checks are green. Sonar passed all six conditions with89.9% new-code coverage, zero duplication and no ignored conditions. All12 new inventory tests ran and passed in the hosted JUnit; source/hash and artifact digest audits passed.
  • Wallet exact-head hosted full/native/coverage/Sonar qualification passed: https://github.com/opensoft/openXwallet/actions/runs/45205563986 .

Exact policy commitment: sha256:21b62c2621f3d98e5358c1ba4c5b0345a0237d10cfa52e59bea122487688979e.

Source-only candidate awaiting owner ratification. T013P07 remains unchecked until later actual complete-graph, real-clock, physical-accounting/privacy/loss controls, full/native/hosted qualification and independent cleanup pass under these fixed limits. Preparation/CI/review does not authorize source acceptance, merge, dependent implementation, setup/dispatch, service/role appointments or live/human/consumer acceptance. Feedback deferred; historical blocked writes unreplayed. GitHub Codex connector review is deferred under the user's explicit local-review instruction.

The actual completed factory checkout is synthetic merge 069c9f88b7221119f421be9a9baac2ac594f0ba6, parents 51503c98c4e03e7f17b390aa8886a6757d3a681d (main) and reviewed head 89dbe6e6640361c36321968725932058aa802e2b. Its tree differs from the reviewed candidate only by the four independently assessed upstream #1364 paths; full suite and Sonar both tested that integration. Artifact source hashes match the reviewed files plus exactly the upstream pin-reader file; all three coverage configs match. This replaces the earlier provisional freshness concern. Recheck refs/checks at any later authorized landing.

@sourcery-ai

sourcery-ai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Schema and migrations

Define the normative requirements for selecting the bounded pilot graph, accounting for nested calls, preserving single-owner allocations, and keeping runtime qualification separate from source ratification.

  • openspec/changes/bound-infrastructure-retirement-accounting/specs/infrastructure-retirement-accounting/spec.md L1-106

Data structures

Specify the proposed accounting limits, ownership evidence, clocks, and call schedule, together with the machine inventory and canonical fixtures that make the proposal reproducible.

  • openspec/changes/bound-infrastructure-retirement-accounting/supporting-docs/accounting-policy.md L1-222
  • openspec/changes/bound-infrastructure-retirement-accounting/supporting-docs/call-inventory.json L1-473
  • openspec/changes/bound-infrastructure-retirement-accounting/supporting-docs/fixtures/final_link.json L1
  • openspec/changes/bound-infrastructure-retirement-accounting/supporting-docs/fixtures/provisioned.json L1
  • openspec/changes/bound-infrastructure-retirement-accounting/supporting-docs/fixtures/reservation.json L1
  • openspec/changes/bound-infrastructure-retirement-accounting/supporting-docs/fixtures/run_receipt.json L1
  • openspec/changes/bound-infrastructure-retirement-accounting/supporting-docs/fixtures/setup_receipt.json L1
  • openspec/changes/bound-infrastructure-retirement-accounting/supporting-docs/inventory-inputs.json L1-102

Implementation

Derive and validate the graph, modeled call totals, fixture measurements, and optional hash-guarded baseline parser checks used to reproduce the inventory.

  • openspec/changes/bound-infrastructure-retirement-accounting/supporting-docs/derive-inventory.py L1-262

Configuration

Register the proposed change in the sequenced-after corpus ledger and record its OpenSpec change metadata.

  • openspec/changes/bound-infrastructure-retirement-accounting/.openspec.yaml L1-13
  • tests/sequenced_after/corpus-ledger.yaml L238

Documentation

Explain the proposal's motivation, review status, historical eligibility evidence, inventory interpretation, source provenance, and later implementation handoff.

  • openspec/changes/bound-infrastructure-retirement-accounting/design.md L1-156
  • openspec/changes/bound-infrastructure-retirement-accounting/proposal.md L1-73
  • openspec/changes/bound-infrastructure-retirement-accounting/supporting-docs/call-inventory.md L1-127
  • openspec/changes/bound-infrastructure-retirement-accounting/supporting-docs/eligibility.md L1-56
  • openspec/changes/bound-infrastructure-retirement-accounting/supporting-docs/fixtures/README.md L1-8
  • openspec/changes/bound-infrastructure-retirement-accounting/supporting-docs/source-context.md L1-28
  • openspec/changes/bound-infrastructure-retirement-accounting/tasks.md L1-26

Tests

Check exact inventory reproduction, graph closure and arithmetic, selected caps, fixture and source-hash tampering, and refusal when baseline inputs or roots are invalid.

  • tests/proposal-support/test_retirement_inventory.py L1-167

Preserve the historical eligibility measurements and their machine-readable diagnostic record as evidence rather than treating them as runtime qualification.

  • openspec/changes/bound-infrastructure-retirement-accounting/supporting-docs/eligibility.json L1-217

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

sourcery-ai[bot]
sourcery-ai Bot previously approved these changes Nov 23, 2026

@sourcery-ai sourcery-ai 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.

Sourcery assessment

Approved.

@sourcery-ai sourcery-ai 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.

Hey - I've found 6 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="openspec/changes/bound-infrastructure-retirement-accounting/supporting-docs/accounting-policy.md" line_range="86-87" />
<code_context>
+one authenticated execution-owner incarnation. It uses a single original
+conditional claim with non-reused ETag. Allocation is prepaid and never refunded.
+Registration acknowledgement is forbidden before its durable claim; an ambiguous
+claim/ack is not permission to resend. The provisioner retains its original
+rollback obligation until actual acknowledged external ownership is established.
+
+A live owner keeps exact before-call counters and byte counts for its prepaid
</code_context>
<issue_to_address>
**Handoff permits competing cleanup**

When the claim is durably written, its acknowledgement is lost, and a cleanup trigger reaches the external owner before the provisioner relinquishes rollback responsibility, the provisioner retains rollback responsibility when the durable claim succeeds but its acknowledgement is lost, while the claimed external owner can accept a cleanup trigger. Both actors can then issue destructive operations against the same resources, breaking single-owner/one-send accounting and leaving cleanup outcomes ambiguous.

Make handoff mutually exclusive: durably fence the provisioner before the external owner can act, and require the provisioner to refuse rollback whenever ownership is ambiguous.
</issue_to_address>

### Comment 2
<location path="openspec/changes/bound-infrastructure-retirement-accounting/supporting-docs/accounting-policy.md" line_range="133-134" />
<code_context>
+grants. policy_digest addresses the exact accepted policy; every identity matches
+independently approved source/authority/current storage provenance. not_after is
+clipped to the approved registration/setup scope. No run/link/incarnation of an
+uncreated resource or chosen operational accepted_commit appears in this anchor.
+
+The immutable cleanup claim has exactly `profile`, `anchor_digest`,
+`allocation_ref`, `owner_incarnation_ref`, `trigger_ref`,
</code_context>
<issue_to_address>
**Cleanup claim can change owners**

When the first cleanup claimant has a different incarnation from the registration allocation owner, a cleanup claim can name an `owner_incarnation_ref` different from the anchor’s `registration_owner_incarnation_ref` while still referencing that anchor and allocation. No equality rule prevents a different process from taking the first cleanup claim, transferring mutation authority without owner loss or renewed governance.

Require the cleanup claim’s owner incarnation to equal the authenticated `registration_owner_incarnation_ref` in the immutable anchor.

Also at `openspec/changes/bound-infrastructure-retirement-accounting/supporting-docs/accounting-policy.md:136`.
</issue_to_address>

### Comment 3
<location path="openspec/changes/bound-infrastructure-retirement-accounting/supporting-docs/call-inventory.md" line_range="9" />
<code_context>
+
+Three VMs, three OS disks, three NICs, one control public IP, one VNet and three
+role-specific NSGs give 14 ephemeral resources and 16 dependency edges. NSG names
+are nsg-wallet-mfa-{control,gate,worker}-qa-01. Each NSG depends on its own NIC and
+the VNet; VNet depends on all three NICs; control IP on control NIC; each disk/NIC
+on its VM. Three subnets are VNet properties, never separate delete targets.
</code_context>
<issue_to_address>
**Azure retirement order fails**

When the inventory graph is used to order retirement, the graph puts the VNet and NSGs before NICs, omits the NIC-to-VNet dependency, and conflicts with the disposition requiring NSGs to be deleted after the VNet. Azure rejects deletes while resources or associations remain, so the selected retirement plan cannot complete.

Correct the dependency paths and per-kind disposition so they encode one Azure-safe retirement order.

Also at `openspec/changes/bound-infrastructure-retirement-accounting/supporting-docs/call-inventory.md:10-11`, `openspec/changes/bound-infrastructure-retirement-accounting/supporting-docs/derive-inventory.py:22`.
</issue_to_address>

### Comment 4
<location path="openspec/changes/bound-infrastructure-retirement-accounting/supporting-docs/accounting-policy.md" line_range="98-100" />
<code_context>
+a single advertised call. Required nested work must be exposed to that same
+meter or use a preassigned, disjoint, independently enforced slice of its pool.
+
+A duplicate trigger can inspect only the original claim and cannot claim another
+cleanup pool. Admit at most four trigger deliveries (one owner plus three duplicate
+checks) under this policy; further delivery is refused before work. There are
+at most three observations of each original creation operation and three of each
+original deletion operation, charged to the same cleanup pool. A failed/uncertain
</code_context>
<issue_to_address>
**Concurrent retries consume cleanup allowance**

When duplicate cleanup-trigger deliveries arrive concurrently, concurrent duplicate deliveries can each inspect the same immutable cleanup claim because the policy defines no atomic admission counter or serialized check for the three-duplicate limit. Those checks consume the shared cleanup pool and can exhaust journal allowance before required cleanup work, leaving retirement incomplete.

Serialize duplicate admission through the original owner or add a durable conditional counter that atomically admits at most three duplicate checks before they consume pool calls.
</issue_to_address>

### Comment 5
<location path="openspec/changes/bound-infrastructure-retirement-accounting/supporting-docs/derive-inventory.py" line_range="51" />
<code_context>
+"basis":{"adapter":"b39feb3a5e9c30f25b28eb55751beb2ad4ff3e87","factory":"afb20ce1df21199e75550e48732b56ee67069c51","provider_sha256":hashlib.sha256((W/"scripts/workload_factory_binding_runtime/azure_composition/provider.py").read_bytes()).hexdigest(),"namespace_sha256":hashlib.sha256((W/"scripts/workload_factory_binding_runtime/azure_composition/namespace.py").read_bytes()).hexdigest()},
</code_context>
<issue_to_address>
**Inventories claim incorrect source provenance**

When the deriver runs against adapter or factory sources different from the recorded basis, `derive-inventory.py` accepts caller-supplied adapter sources but emits fixed adapter and factory revisions; it also hashes only provider and namespace files, not the imported selection and fixture helpers. The generated inventory can therefore claim provenance from sources that did not generate it, misleading reviewers about the evidence.

Derive the recorded revisions and source hashes from the exact code used, covering all imported helpers that affect the generated inventory.

Also at `openspec/changes/bound-infrastructure-retirement-accounting/supporting-docs/derive-inventory.py:9-11`.
</issue_to_address>

### Comment 6
<location path="openspec/changes/bound-infrastructure-retirement-accounting/supporting-docs/accounting-policy.md" line_range="81-83" />
<code_context>
+
+## Durable ownership without a recursive metering journal
+
+Before ownership handoff or a first destructive send, the trusted external
+registration service durably assigns the entire fixed maximum allocation to
+one authenticated execution-owner incarnation. It uses a single original
+conditional claim with non-reused ETag. Allocation is prepaid and never refunded.
+Registration acknowledgement is forbidden before its durable claim; an ambiguous
</code_context>
<issue_to_address>
**Observer cannot use the reserved allocation**

When the execution owner is lost while reconciliation or a late observation is still needed, the registration service assigns the entire prepaid allocation to one execution-owner incarnation, but the separate observer has no authority to spend the observation pool. The unused allocation is stranded, so the promised reconciliation cannot proceed.

Define and durably authorize how the observer can use the observation pool after owner loss without contradicting the single-owner allocation.

Also at `openspec/changes/bound-infrastructure-retirement-accounting/supporting-docs/accounting-policy.md:127-128`.
</issue_to_address>

Sourcery assessment

Approval pending. 6 findings to address first.

Blocking findings: openspec/changes/bound-infrastructure-retirement-accounting/supporting-docs/accounting-policy.md:87, openspec/changes/bound-infrastructure-retirement-accounting/supporting-docs/accounting-policy.md:134, openspec/changes/bound-infrastructure-retirement-accounting/supporting-docs/call-inventory.md:9, openspec/changes/bound-infrastructure-retirement-accounting/supporting-docs/accounting-policy.md:100, openspec/changes/bound-infrastructure-retirement-accounting/supporting-docs/derive-inventory.py:51, and 1 more


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@sonarqubecloud

Copy link
Copy Markdown

@brettheap
brettheap merged commit 5878417 into main Nov 23, 2026
21 checks passed
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