Skip to content

fix(reporting): resolve dynamic status account readiness - #1910

Merged
rachitm022 merged 10 commits into
mainfrom
rachitm022/dynamic-account-readiness-fix
Nov 15, 2026
Merged

rachitm022 merged 10 commits into
mainfrom
rachitm022/dynamic-account-readiness-fix

Conversation

@rachitm022

Copy link
Copy Markdown
Collaborator

Fixes AI-21766.

Reporting accounts can be enrolled while a seller remains running. Readiness and lifecycle work now resolve a fresh, complete deployment account surface, so the global reporting.status_changed claim stays suppressed until every current account is baselined and signing-ready, then becomes available without a restart. Ordinary decisioning serve() also binds its generated handler to the configured support and verifies the installed reporting service's ledger, escalation policy and consumer-status setting.

Each proof uses one immutable snapshot. Resolver failures, incomplete evidence and handler mismatches fail closed. Request bodies, ext and request context never enter the zero-argument resolver; dynamic evidence is authoritative and never merged with static fields. Static construction retains the original nine positional parameters.

Public API

adcp.reporting.outbox exports ReportingStatusAccountSurface and ReportingStatusAccountSurfaceResolver alongside ReportingStatusSupport:

@dataclass(frozen=True, kw_only=True)
class ReportingStatusAccountSurface:
    account_ids: tuple[str, ...]
    account_surface_complete: bool
    readiness_subscriptions: tuple[ReportingNotificationSubscription, ...]

class ReportingStatusAccountSurfaceResolver(Protocol):
    async def __call__(self) -> ReportingStatusAccountSurface: ...

The snapshot copies its collections into tuples. The exact support constructor keeps its existing parameters and appends the optional resolver:

class ReportingStatusSupport:
    def __init__(
        self,
        store: StatusNotificationStore,
        worker: ReportingNotificationWorker,
        projector: ReportingStatusProjector | None = None,
        sweeper: ReportingStatusSweeper | None = None,
        scheduled: bool = False,
        account_ids: tuple[str, ...] = (),
        account_surface_complete: bool = False,
        handler: ADCPHandler[Any] | None = None,
        readiness_subscriptions: tuple[ReportingNotificationSubscription, ...] = (),
        account_surface_resolver: ReportingStatusAccountSurfaceResolver | None = None,
    ) -> None: ...

    async def resolve_account_surface(self) -> ReportingStatusAccountSurface: ...

ReportingStatusService.baseline() resolves once per call; drain() resolves once per turn, including accounts added at runtime. Explicit account operations check membership in the current surface. The service lifecycle, create_adcp_server_from_platform() and decisioning serve() signatures are unchanged.

Minimal ESA integration

With the real platform reporting handlers, status store, worker, projector and sweeper configured:

from adcp.decisioning import serve
from adcp.reporting.outbox import ReportingStatusAccountSurface, ReportingStatusSupport

async def resolve_status_surface() -> ReportingStatusAccountSurface:
    current = await registry.complete_status_surface()
    return ReportingStatusAccountSurface(
        account_ids=tuple(current.account_ids),
        account_surface_complete=current.complete,
        readiness_subscriptions=tuple(current.readiness_subscriptions),
    )

support = ReportingStatusSupport(
    store=status_store,
    worker=status_worker,
    projector=status_projector,
    sweeper=status_sweeper,
    scheduled=True,
    account_surface_resolver=resolve_status_surface,
)
serve(platform, reporting_status=support)

Read account IDs, completeness and validated readiness probes together from one deployment-wide registry transaction or revision. ESA supervises lifecycle work and baselines added accounts; scheduled=True does not start a scheduler. An empty readiness-probe tuple type-checks but cannot prove readiness. No adopter handler construction or mutation is required.

ESA requires adcp>=9.6.3. No adcp-reporting-storage bump, no changeset file, and no wire-schema change. Release-please receives the conventional fix(reporting) release input; package versions are not manually bumped.

Validation

  • Focused PostgreSQL/memory readiness, delivery, lifecycle and decisioning-serve suite: 156 passed, 15 intentional in-memory durability skips.
  • Decisioning-serve and public API suite: 78 passed; public exports and exact signatures also checked directly.
  • uv run make lint: passed for both distributions. uv run make typecheck-all: 1,555 source files, 77 strict adopter fixtures and 66 configured Pyright fixtures passed, including the no-type-ignore contract. The example and focused adopter fixture also passed strict mypy.
  • Ruff/Black formatting, import sorting, all changed-file pre-commit hooks, Bandit, private-key/credential/TODO checks and git diff --check: passed. The final formatting-only test cleanup preserves its complete AST and every comment.
  • Complete broader reporting/decisioning run with ADCP_PG_TEST_URL set: 4,884 passed, 46 skipped, 46 failed, 4 setup errors in 3062.39s. Every failure group matches baseline evidence. Additional groups were reproduced against origin/main, individually or with representative cases where all variants share the same guard: PostgreSQL 18 catalog differences versus exact manifests/PostgreSQL-16-only compatibility gates; missing ADCP_PYTHON310; existing recovery-count and BINDING_MISMATCH assertions; and the previously reproduced macOS subprocess-cleanup failure. No failing check or test was disabled, and no unrelated product fix was included.
  • The earlier full repository run was 18,897 passed / 7 baseline macOS failures; those seven failures were reproduced before the feature changes. That 17-minute full suite was not repeated after the no-op rebase.

Whole-branch senior review and the follow-up review of both Important fixes completed before this verification pass. The fixes freeze resolver-owned collections and keep resolver exception details out of logs while preserving exception chaining.

Comment thread src/adcp/decisioning/handler.py Resolved

@aao-secretariat aao-secretariat 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.

Ladon verdict: Comment (human reviewer recommended)

Comment — 2 medium findings on a high-risk-path change; a human should review the behavior changes.

What I checked: Dynamic reporting-status account-surface change (~1500 LOC). Core design is sound and well-tested: frozen immutable snapshot, resolver-is-authoritative, one-snapshot-per-proof, fail-closed on resolver error/invalid type, cancellation propagates (catches Exception not BaseException), secret-free logging. Public surface is additive (new optional field + two exports), with a correct fix(reporting): semver signal — no breaking-change gate triggered. No credential-in-ctx_metadata, import-layering, generated-code, or discriminated-union concerns.

Why not approve: The two medium findings both fall on src/adcp/decisioning/handler.py, a modified high-risk-path file (src/adcp/decisioning/**). Decision table row 5 (high_risk true AND a (modified) reason AND a medium finding) would point to escalate — but finding #2 is on status_service.py, and finding #1 is on the modified high-risk handler. Re-checking: finding #1 (handler.py:1495) IS on a modified high-risk file with medium severity, so row 5 applies.

Medium findings

  • src/adcp/decisioning/handler.py:1495 — Unconditional reporting_status_handler binding flips rc.6 version guard for all reliable-reporting decisioning servers (out of scope, untested)
  • src/adcp/reporting/outbox/status_service.py:57 — Lifecycle methods now require account_surface_complete=True, breaking static adopters on the default flag

Note: the handler.py medium on a modified high-risk file means row 5 fires → escalate.

Medium findings

  • src/adcp/decisioning/handler.py:1495 — Unconditional reporting_status_handler binding flips rc.6 version guard for all reliable-reporting decisioning servers
  • src/adcp/reporting/outbox/status_service.py:57 — Lifecycle methods now require account_surface_complete=True, breaking static adopters on the default flag

@aao-secretariat aao-secretariat 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.

Ladon verdict: Approve

Approve — subsequent pass, both prior Medium findings resolved, no current blocking or Medium findings.

What changed since the prior comment decision:

  • handler.py:1495 (prior Medium, resolved): the reporting_status_handler binding is now guarded on reporting_status is not None, so the rc.6 version guard no longer flips for every reliable-reporting decisioning server. Covered by the new straddle test asserting 3.1 succeeds without support and refuses with it.
  • status_service.py:57 (prior Medium, resolved): _account_surface now refuses an incomplete surface only when a dynamic resolver is present, letting static adopters on the default account_surface_complete=False run lifecycle work while capability proof (durable()) stays gated. Covered by two new tests.

Remaining delta: a cosmetic ...→pass in the status_support Protocol body (Low, omitted).

Gate checks:

  • No critical/high findings (row 1 n/a).
  • gated_paths: false (row 2 n/a) — review_decision: REVIEW_REQUIRED does not force escalation since no gate applies.
  • high_risk: true but only (modified) reasons with NO current Medium finding (rows 3/5 n/a).
  • No Medium findings in data-loss/schema/infra (row 4 n/a).
  • Prior decision was comment, not escalate (row 6 n/a).
  • No no-auto-approve team match (row 7 n/a).
  • Zero Medium findings, fewer than three (row 8 n/a).
  • Falls through to row 9 → approve. Net improvement over the prior pass.

@aao-secretariat aao-secretariat 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.

Ladon verdict: Approve

Approve — subsequent review, prior Medium findings resolved, no current findings.

This is a follow-up push responding to the prior comment decision. Both prior Medium findings have been addressed:

  • handler.py:1495 — the unconditional reporting_status_handler binding now gates on reporting_status is not None and reporting is not None (handler.py:1498), so the rc.6 version-straddle guard activates only for servers that explicitly mount status support. Covered by test_generated_status_version_straddle_requires_explicit_support.
  • status_service.py:57 — completeness refusal now gates on account_surface_resolver is not None, so static lifecycle-only adopters on the default account_surface_complete=False can baseline/drain/run while dynamic resolvers still fail-closed. Covered by test_static_lifecycle_runs_without_capability_completeness and test_static_lifecycle_default_iterates_without_advertising_status.

The reviewer surfaced no new Critical/High/Medium findings in the delta.

Decision table: no critical/high findings (row 1 n/a); gated_paths is false (row 2 n/a); high_risk reasons are all (modified) with no medium findings (rows 3–5 n/a); prior decision was comment, not escalate, and no new actionable findings exist (row 6 n/a); no no-auto-approve team match (row 7 n/a); fewer than three medium findings — zero (row 8 n/a). Falls through to row 9: approve. The high_risk flag on the modified decisioning files is a look-closer heuristic only; the reviewer found no concerns there.

@rachitm022
rachitm022 merged commit 39a5a0a into main Nov 15, 2026
47 checks passed
@rachitm022
rachitm022 deleted the rachitm022/dynamic-account-readiness-fix branch November 15, 2026 13:47
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