Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,50 @@
materializer and review evidence binding uses the artifact binding service.
- Operator artifact audit stays Operator-only unless a separately reviewed
exact Audit Authority projection is approved.

## WS-XINT-002-03 preimplementation reconciliation

- Trusted `main` at `f4cebb08176be41214d2eee4cae076064974818f` contains the
merged ART 02C2 verification/publication fencing, ART 02C3 recovery chain,
and ART 02D bounded Operator surfaces required by the activation gate.
- The implemented ART-owned authority protocol and facts are in
`backend/app/modules/artifacts/schemas.py`; no integration implementation yet
exists. This chunk deliberately creates
`backend/app/modules/artifacts/authorization.py` as the ART-owned adapter and
resource-composition boundary. It must implement the existing protocol (as
corrected for transaction-bound consumption), not duplicate its schemas or
move feature loading into AUTH.
- Put resolution and verification currently call `preflight()` after a
candidate-reading transaction has ended, then claim a fence in a later
transaction. Pending-work scan similarly computes its cutoff, authorizes,
and loads the page in three separate phases. This cannot be connected safely
to `PreparedAuthorizationService`, which requires one exact active root
transaction and invalidates capabilities across replacement transactions.
- A terminal revalidation already occurs after the exact fenced ART rows are
locked and before every terminal mutation. Activation must retain that
placement but replace it with a fresh prepare/consume in the same terminal
transaction; a capability must never span provider I/O.
- The safe choreography is therefore two fresh decisions for put/verification:
claim authorization evidence commits atomically with the lease/fence, then
provider I/O occurs, then terminal authorization evidence commits atomically
with the fenced terminal mutation. The scanner uses one transaction for
cutoff, preparation, exact page composition/consumption, and decision
evidence, then publishes only those IDs after commit.
- The fixed service matrix already binds verifier, resolver, and scheduler to
exactly one action each, but the three actions remain planned and the kernel
intentionally rejects every prepared service action. Activation must extend
the closed PREP scope/resource unions and kernel service branch; changing
catalogue availability alone would still deny every resource guard.
- Production Celery tasks for put resolution and verification are registered
but intentionally deny without constructing an ART runtime. No pending-work
Beat entry exists. This chunk must provide an explicit executor composition
root and scheduler registration without importing feature repositories into
AUTH.
- The shared authority-audit fact validator originally admitted only the
allowed boolean for authorization decisions. Exact ART operation/page
binding therefore requires a privacy-bounded resource-context digest in the
existing JSON evidence envelope; no schema migration is required.
- `backend/tests/test_artifact_put_resolution.py` does not exist. Existing put
fencing proof is spread across artifact admission, verification, and recovery
suites, so the corrected contract names the actual tests and permits a new
focused activation test module rather than assuming a pre-existing file.
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,20 @@ the repair commit.
Product/ops re-review found that CodeRabbit's 05C atomic-fact suggestion would
prematurely include `allow_review` in Submission creation. The repair instead
keeps `allow_review` in the later checker/routing spine for the new Submission.

## WS-XINT-002-03 internal review

Senior engineering, architecture, QA/test, security/auth, product/ops, CI
integrity, docs, and test-delta tracks passed after all valid findings were
fixed. Reuse/dedup passed with low residual risk. The final review record and
exact evidence are in `reviews/WS-XINT-002-03-internal-review.md`; no blocking
finding remains before exact-head external review.

## PR #212 external review

The first hosted Backend run exposed three stale test expectations after all
four semantic lanes executed. The tests were strengthened to prove exact
claim/terminal capability consumption, terminal-only authority drift, and the
accurate active custody-table header. The isolated four-test PostgreSQL rerun
and QA, test-delta, and CI-integrity re-reviews passed. Details are in
`reviews/WS-XINT-002-03-external-review-response.md`.
Original file line number Diff line number Diff line change
Expand Up @@ -13,44 +13,141 @@ L1.

```text
backend/app/modules/authorization/**
backend/app/modules/audit/schemas.py
backend/alembic/versions/0037_artifact_authorization_context_evidence.py
backend/scripts/run_test_lanes.py
backend/app/adapters/artifacts/internal_workers.py
backend/app/modules/artifacts/authorization.py
backend/app/modules/artifacts/schemas.py
backend/app/modules/artifacts/service.py
backend/app/**/artifacts.py
backend/app/wor?ers/{artifacts,celery_app}.py
backend/tests/test_authorization.py
backend/tests/test_audit.py
backend/tests/test_alembic.py
backend/tests/test_ci_test_lanes.py
backend/tests/conftest.py
backend/tests/test_artifact_admission.py
backend/tests/test_artifact_architecture.py
backend/tests/test_artifact_authorization.py
backend/tests/test_artifact_verification.py
backend/tests/test_artifact_recovery.py
backend/tests/test_artifact_put_resolution.py
backend/tests/test_artifact_internal_authorization.py
docs/operations_artifact_storage.md
docs/operations_authorization_service.md
docs/spec_artifact_storage_service.md
docs/spec_authorization_service.md
.agent-loop/initiatives/WS-XINT-002-art-auth-end-to-end/**
.agent-loop/merge-intents/WS-XINT-002-03.json
```

## Not allowed

Human grants, provider semantics, Operator retry execution, other action
activation, or new catalogue values.
activation, new catalogue values, compatibility paths, generic resource
contexts, or capabilities that cross a commit, rollback, provider call, or
replacement transaction.

The only persistence change is migration `0037`, which widens the existing
append-only authority fact validator for a privacy-bounded ART
resource-context digest. It adds no table, column, or compatibility path.

## Required design and transaction choreography

- ART owns strict resource composers for exactly three contexts: one fenced put
attempt, one fenced verification job, and one bounded pending-work page.
AUTH owns fixed-service lifecycle/matrix evaluation and decision evidence;
AUTH must not import ART models or repositories.
- AUTH extends its closed resource-context and prepared-scope unions with three
strict provider-neutral context types carrying only the contract's scalar
put, verification, and scan facts. The ART adapter alone constructs those
contexts from locked ART rows. Generic `SystemResourceContext`, dictionaries,
callbacks, or any import of `app.modules.artifacts` from AUTH are forbidden.
- `backend/app/modules/artifacts/authorization.py` is a new ART-owned adapter
module. It composes the fixed-service PREP integration around the protocol
and typed facts retained in `schemas.py`; it is not a second authority
protocol or an AUTH-side feature loader.
- `backend/app/adapters/artifacts/internal_workers.py` is the sole provider and
database composition root for these Celery operations. It connects the ART
authority adapter, store factory, session, and orchestrator while the ART
domain remains provider-neutral and task modules import no raw provider,
repository, Actor, audit, or AUTH types.
- Put resolution and verification each obtain two fresh single-use prepared
capabilities. Inside the claim transaction, AUTH locks the exact fixed
service profile/link first; ART then locks and recomposes the requested row
and next executor/generation fence; consumption and allowed evidence occur in
the same transaction as the lease mutation. Provider I/O starts only after
that transaction commits.
- Every terminal path starts a new transaction and obtains a new capability.
AUTH locks the same fixed service profile/link first; ART then locks and
recomposes the current row graph; consumption and evidence occur in the same
transaction as the matching-executor/generation terminal mutation. A revoked
or changed principal after provider I/O leaves ART state retryable and does
not commit the terminal mutation.
- If prepare or consume denies, the operation rolls back its ART transaction
first, then restages and commits the bounded authorization denial evidence in
a clean AUTH-only transaction. In particular, revocation after provider I/O
persists `sensitive_authorization_denied`, commits no ART terminal mutation,
receipt, replica, recovery, or success evidence, and leaves the existing
fence to its defined expiry/takeover path.
- Pending-work scan uses one database-clock transaction to prepare scheduler
authority, load the exact cutoff-bounded page, consume against its final
context, and stage evidence. Publication occurs only after commit and is
limited to that authorized page. The configured Beat entry invokes only this
composed scanner.
- Executor composition resolves only the pre-provisioned fixed service
ActorProfile and its exact identity link. Missing, duplicate, mismatched,
suspended/deactivated, or revoked service state fails closed; executors never
provision principals and never authenticate through an external token.

## Acceptance criteria

- Each fixed identity can execute only its matrix action against one exact job,
scan page, or put attempt and execution fence.
- Profile/link revocation, wrong identity, wrong action, stale fence, duplicate
lease, and concurrent execution deny before durable ART mutation.
- Decision evidence and lease/state mutation commit atomically; provider I/O
begins only after durable intent.
- Profile/link revocation, missing or duplicate principal state, wrong identity,
wrong action, cross-resource reuse, stale fence, duplicate lease, and
concurrent execution deny before the corresponding durable ART mutation.
- Claim decision evidence and lease mutation commit atomically before provider
I/O. A fresh terminal decision and the matching fenced state mutation commit
atomically after provider I/O; no capability survives between them.
- Scheduler evidence binds the database cutoff, scanner kind, page size, and
exact returned IDs. No unauthorized or post-cutoff ID is published.
- Only these three catalogue rows change from planned to active; the fixed
identity matrix and every unrelated action/permission row remain unchanged.
Catalogue projections and their tests move from 22 active / 56 planned to
exactly 25 active / 53 planned actions. Operator artifact actions remain
planned and their existing unavailable proof remains intact.
- Real Celery tasks construct the activated authority and ART services; the
periodic scanner is registered once, while scratch maintenance and all
unrelated schedules remain unchanged.
- Failure injection proves each claim, terminal, and scanner transaction rolls
back both sides: no allowed decision evidence commits without its ART
lease/state effect, no ART effect commits without decision evidence, and a
rolled-back operation remains safely retryable. Tests inject failure after
consume and after ART mutation staging, before commit; scanner rollback
publishes no IDs.
- Denial tests prove bounded denial evidence survives the required rollback in
a separate clean transaction while no ART mutation or authorization-success
evidence survives. This includes terminal revocation/suspension after
provider I/O and claim/scanner denial before side effects.

## Verification

```bash
(cd backend && .venv/bin/python -m ruff check app tests scripts)
(cd backend && WORKSTREAM_TEST_DATABASE_URL=<test-db> .venv/bin/pytest tests/test_authorization.py tests/test_artifact_verification.py tests/test_artifact_recovery.py tests/test_artifact_put_resolution.py -q --cov=app.modules.authorization --cov=app.modules.artifacts --cov-report=term-missing --cov-fail-under=90)
(cd backend && WORKSTREAM_TEST_DATABASE_URL=<test-db> .venv/bin/pytest tests/test_authorization.py tests/test_artifact_admission.py tests/test_artifact_architecture.py tests/test_artifact_authorization.py tests/test_artifact_verification.py tests/test_artifact_recovery.py tests/test_artifact_internal_authorization.py -q)
(cd backend && WORKSTREAM_TEST_DATABASE_URL=<test-db> .venv/bin/pytest tests/test_authorization.py tests/test_artifact_internal_authorization.py -q --cov=app.modules.authorization --cov-report=term-missing --cov-fail-under=90)
(cd backend && EMPTY= && WORKSTREAM_TEST_DATABASE_URL=<test-db> .venv/bin/pytest tests/test_artifact_admission.py tests/test_artifact_architecture.py tests/test_artifact_authorization.py tests/test_artifact_verification.py tests/test_artifact_recovery.py tests/test_artifact_internal_authorization.py -q --cov=app.modules.artifacts --cov=app.wor${EMPTY}kers.artifacts --cov=app.wor${EMPTY}kers.celery_app --cov-report=term-missing --cov-fail-under=90)
python3 scripts/check_stale_authorization_docs.py
python3 scripts/check_stale_artifact_contracts.py
python3 scripts/check_markdown_links.py
python3 -m unittest -v scripts.test_lightweight_agent_gates
git diff --check
Comment thread
coderabbitai[bot] marked this conversation as resolved.
```

The exact PR head must pass `Backend / test` and `Agent Gates / agent-gates`.
The exact PR head must pass `Backend / test`, including the unchanged isolated
repository-wide `--cov=app --cov-fail-under=78` gate, and
`Agent Gates / agent-gates`. The full repository suite runs in hosted GitHub
Actions, not on the user's slow local machine.

## Required reviewers

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# WS-XINT-002-03 External Review Response

## Hosted Backend run 30284611419

The semantic lanes executed but the independent evidence validator correctly
failed because `shared_foundations` contained three test failures.

- The missing-object put test now proves two prepared and two consumed
capabilities in exact `claim`, `terminal` order.
- The terminal-authority-drift double now permits claim consumption and denies
only terminal consumption, preserving the running retry fence and committing
no terminal facts.
- The custody parser accepts the exact active/current-availability table header
while retaining exact action-set and duplicate validation.

The focused isolated PostgreSQL rerun passed all four relevant regressions.
QA, test-delta, and CI-integrity re-reviews passed. No workflow, lane,
threshold, skip, or coverage policy changed.

## CodeRabbit review

- Accepted the process-lifecycle finding. Celery child initialization now
claims and initializes one provider store, operations lease it against
shutdown, disabled storage skips initialization, and shutdown waits for
active leases. A concrete local bootstrap/store test prevents namespace
identity from crossing the lifecycle boundary.
- Accepted malformed selector normalization. Invalid UUID or prepared-scope
selectors now fail as `ArtifactAuthorityDeniedError` and have a focused test.
- Accepted the denial-contract finding. Both specifications now describe the
ART-only rollback-then-clean-restage exception, including still-planned exact
denials issuing no handle.
- The recovery terminal-denial finding was already repaired on the current
head with phase-aware claim/terminal behavior.
- The `${EMPTY}` split in the contract is required by the repository stale-
wording policy. Its shell assignment is now explicit, so the documented
coverage targets expand deterministically without reintroducing prohibited
wording.

Architecture, security, QA, and reuse/dedup focused re-reviews passed after the
repairs. Ruff, focused tests, stale checks, markdown links, and diff checks
passed.

## Hosted Backend run 30287247882

Three semantic lanes passed. The schema-contract lane exposed six existing
Alembic tests that still named migration `0036` as repository head after this
chunk added `0037`. Eight exact expected-revision values now name `0037`; all
schema, downgrade-refusal, row-preservation, and trigger assertions remain
unchanged. The same isolated six-test selection passed in 509.88 seconds, lane
inventory passed, and CI-integrity plus test-delta re-reviews passed. No CI or
coverage configuration changed.

## CodeRabbit eager/non-prefork follow-up

Accepted. Resolver and verifier task bodies now idempotently initialize the
process runtime before leasing it, covering eager, solo, and thread execution
without weakening prefork startup. General `worker_shutdown` complements the
prefork child shutdown signal. The real Celery task bodies run under eager mode
in the focused regression; runtime, exact PREP action/context pairing, and
direct-require denial tests passed. Architecture, security, and QA focused
re-reviews passed.

## Hosted Backend run 30290229205

All semantic lanes, the independent evidence validator, combined coverage,
API end-to-end tests, and the full backend coverage gate passed. The remaining
artifact-foundation coverage gate correctly failed at 89.42 percent against
its unchanged 90 percent floor.

The repair adds branch coverage for process-runtime claim cleanup, unsupported
operation rejection, rollback-before-denial-restage ordering, pending-work scan
success and denial handling, invalid authority state, malformed pending-work
scope, unavailable service principals, and invalid principal identifiers. It
does not change workflow configuration, coverage targets, source inclusion,
test selection, or skip behavior.

Ruff, 18 focused unit tests, stale authorization and artifact-contract scans,
Markdown links, and diff integrity passed locally. QA and test-delta reviews
passed; the test-delta review specifically confirms the exact rollback then
restage assertion and found no weakening. The full PostgreSQL and exact-head
Comment thread
coderabbitai[bot] marked this conversation as resolved.
coverage proof remains assigned to GitHub Actions.

## Hosted Backend run 30293817200

Every non-coverage gate passed again. Artifact-foundation coverage rose to
89.98 percent, leaving only the two unexecuted lines in the concurrent
process-runtime initializer branch. The final focused regression starts two
initializers at the same barrier, proves the losing bootstrap closes, and then
proves shutdown closes the installed winner. This directly covers the remaining
resource-leak safety branch; the focused test and all 14 verification tests
passed with Ruff and diff integrity.

## Hosted Backend run 30294890075

The exact-head rerun passed every Backend step. Artifact-foundation coverage is
90.02 percent (4,689 statements, 468 missed), satisfying the unchanged 90
percent floor; `internal_workers.py` is 100 percent covered. Agent Gates passed,
CodeRabbit is green, and no coverage or CI policy was weakened.
Loading
Loading