-
Notifications
You must be signed in to change notification settings - Fork 7
WS-CON-001-02C: add shared lifecycle audit participant #277
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
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
00e8d81
feat(audit): add lifecycle transaction participant
Abiorh001 9e409d6
fix(audit): align lifecycle event contract
Abiorh001 4439538
test(audit): enforce lifecycle source lineage
Abiorh001 0e0a02a
Merge branch 'main' into codex/ws-con-001-02c-lifecycle-audit
abiorh-claw 43c29e0
fix(audit): require exact lifecycle references
Abiorh001 6c42fbb
docs(audit): record 02c review evidence
Abiorh001 7520be3
Merge remote-tracking branch 'origin/codex/ws-con-001-02c-lifecycle-a…
Abiorh001 c3139b4
docs(audit): reconcile 02c with latest main
Abiorh001 0f63323
test(audit): clean lifecycle replay fixtures
Abiorh001 3f330f0
docs(audit): use actor-neutral scope wording
Abiorh001 afad651
test(audit): bind replay waiter to event lock
Abiorh001 8f173a0
docs(audit): publish professional 02c trust bundle
Abiorh001 6dd5678
docs(audit): clarify lifecycle compatibility wording
Abiorh001 638ad49
docs(audit): polish trust bundle wording
Abiorh001 7b2e1e4
Merge branch 'main' into codex/ws-con-001-02c-lifecycle-audit
abiorh-claw b9853de
Merge branch 'main' into codex/ws-con-001-02c-lifecycle-audit
abiorh-claw 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
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
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
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
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
46 changes: 46 additions & 0 deletions
46
...bution-compensation-boundary/reviews/WS-CON-001-02C-internal-review-evidence.md
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,46 @@ | ||
| # Internal Review Evidence: WS-CON-001-02C | ||
|
|
||
| ## Scope | ||
|
|
||
| 02C adds a typed, feature-neutral lifecycle-audit participant over the existing | ||
| append-only `audit_events` ledger. It uses the caller's `AsyncSession`, flushes | ||
| without committing, and adds no schema, migration, route, worker, AUTH, REV, | ||
| CON product behavior, or outbox behavior. | ||
|
|
||
| Current reconciled main: `9865456b3fb1f6048f4c7b7aef4dac71fbf3323e`. | ||
|
|
||
| ## Deterministic evidence | ||
|
|
||
| ```text | ||
| 39 isolated PostgreSQL audit tests passed before final main reconciliation | ||
| 26 focused lifecycle tests passed again after final main reconciliation | ||
| 11 schema-only lifecycle input tests passed | ||
| audit subsystem coverage: 94.64% (required at least 90%) | ||
| Ruff: passed | ||
| git diff --check: passed | ||
| Markdown links: passed | ||
| stale Workstream wording: passed | ||
| ``` | ||
|
|
||
| The proof covers caller rollback, exact persisted replay, changed replay | ||
| conflict, deterministic concurrent replay through an observed PostgreSQL | ||
| advisory-lock waiter, fixed internal provenance, complete canonical event/entity | ||
| mapping, exact event-specific UUID references, reason/status consistency, | ||
| generic repository bypass denial, and forged-input secret non-retention. | ||
|
|
||
| ## Review state | ||
|
|
||
| Preimplementation architecture review passed with low-risk conditions. Those | ||
| conditions were implemented: the participant uses the existing | ||
| lifecycle-compatible `audit_events` representation, fixes internal provenance | ||
| itself, has a dedicated | ||
| repository replay path with an explicit immutable comparison set, raises a | ||
| non-leaking typed conflict, and prevents the generic repository from | ||
| impersonating it. | ||
|
|
||
| Required internal postimplementation review is complete. Senior engineering, QA, | ||
| security, product/ops, architecture, docs, reuse/dedup, and test-delta all | ||
| passed after their valid findings were repaired. Repairs included canonical | ||
| PascalCase REV/CON event ownership, exact source-lineage reference sets, | ||
| removal of ambiguous authority/generic contribution tokens, complete state | ||
| endpoints, deterministic concurrent replay proof, and current initiative docs. | ||
166 changes: 166 additions & 0 deletions
166
...01-contribution-compensation-boundary/reviews/WS-CON-001-02C-pr-trust-bundle.md
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,166 @@ | ||
| # WS-CON-001-02C PR Trust Bundle | ||
|
|
||
| ## Chunk | ||
|
|
||
| `WS-CON-001-02C` — Shared Lifecycle Audit Participant. | ||
|
|
||
| ## Goal | ||
|
|
||
| Provide the flush-only, caller-transaction audit participant required by future | ||
| REV and CON lifecycle transactions without creating a second ledger or taking | ||
| commit ownership. | ||
|
|
||
| ## Human-approved intent | ||
|
|
||
| Workstream must record bounded canonical lifecycle evidence in the same | ||
| transaction as the product facts it describes. This chunk supplies that shared | ||
| boundary only; it does not implement review, contribution, compensation, or | ||
| outbox lifecycle behavior. | ||
|
|
||
| ## What changed | ||
|
|
||
| - Added closed canonical REV/CON lifecycle event, entity, reason, and reference | ||
| types. | ||
| - Enforced exact event-to-entity and event-to-reference contracts, including | ||
| FinalAcceptance, reviewer/submitter contribution, and award lineage. | ||
| - Added `LifecycleAuditParticipant` over the existing `audit_events` ledger and | ||
| caller-owned `AsyncSession`. | ||
| - Added exact replay handling and changed-replay conflict behavior serialized by | ||
| a transaction-scoped PostgreSQL advisory lock. | ||
| - Reserved fixed internal provenance and blocked generic-repository bypass. | ||
| - Added rollback, privacy, replay, concurrency, vocabulary-completeness, and | ||
| lineage tests. | ||
| - Reconciled 02C status and evidence with current main, REV-03A2, and migration | ||
| head `0056_review_lease_preference`. | ||
|
|
||
| ## Why it changed | ||
|
|
||
| Future REV decision and CON contribution/award transactions need audit evidence | ||
| to succeed or roll back atomically with their domain rows. The previous generic | ||
| repository path accepted unbounded compatibility shapes and did not define | ||
| deterministic concurrent replay behavior. | ||
|
|
||
| ## Design chosen | ||
|
|
||
| The participant reuses the existing lifecycle-compatible `audit_events` | ||
| representation. Its persisted discriminator remains `legacy_lifecycle`, but | ||
| that compatibility token is not exposed as the interface name or product | ||
| boundary. Callers can supply only typed canonical facts. It flushes through the | ||
| caller's session and never commits or creates a session. Exact event-ID replay | ||
| returns the existing immutable row; changed reuse raises a non-leaking | ||
| `LifecycleAuditConflict`. A transaction-scoped advisory lock serializes the | ||
| read/insert decision for that event ID. | ||
|
|
||
| Nested `project_id` is provenance evidence only. Authorization and filtering | ||
| must reload the canonical entity chain rather than trusting audit payload data. | ||
|
|
||
| ## Alternatives rejected | ||
|
|
||
| - A second lifecycle audit table or event domain: duplicate ledger authority. | ||
| - Participant-owned sessions or commits: breaks atomic REV/CON transactions. | ||
| - Arbitrary event names or metadata: permits semantic and privacy drift. | ||
| - Unique-constraint failure as replay behavior: leaks a storage concern and is | ||
| nondeterministic for callers. | ||
| - Authorization-link events in this participant: canonical authority decisions | ||
| remain owned by the typed authority audit boundary. | ||
|
|
||
| ## Scope control | ||
|
|
||
| Changed runtime scope is limited to: | ||
|
|
||
| - `backend/app/modules/audit/{schemas,repository,service}.py` | ||
| - `backend/tests/test_audit.py` | ||
| - the exact shared-audit architecture note and WS-CON-001 loop evidence | ||
|
|
||
| No model, migration, route, background executor, feature service, dependency, | ||
| workflow, CI threshold, outbox dispatcher, review command, contribution | ||
| persistence, compensation fulfillment, or reputation behavior changed. | ||
|
|
||
| ## Product behavior | ||
|
|
||
| No user-facing lifecycle is activated. The shared contract distinguishes | ||
| `accept`, `needs_revision`, and `reject`; only acceptance evidence may reference | ||
| FinalAcceptance. Reviewer and submitter contribution evidence use distinct exact | ||
| source shapes. Generic or ambiguous contribution events are not admitted. | ||
|
|
||
| ## Acceptance criteria proof | ||
|
|
||
| - Caller rollback removes staged lifecycle evidence. | ||
| - The participant flushes without commit and opens no independent session. | ||
| - Event vocabulary and primary-entity mappings are complete and closed. | ||
| - Event references are exact; unrelated lineage is rejected. | ||
| - Exact replay succeeds and changed replay fails closed. | ||
| - Concurrent replay waits on the exact event advisory lock. | ||
| - Generic repository bypass and forged secret-bearing input are rejected. | ||
| - The existing append-only ledger remains the only audit store. | ||
|
|
||
| ## Tests and checks run | ||
|
|
||
| - 39 isolated PostgreSQL audit tests passed before final main reconciliation. | ||
| - 26 focused lifecycle tests passed again after reconciliation with current | ||
| main and migration `0056`. | ||
| - 11 schema-only lifecycle input tests passed. | ||
| - Audit subsystem coverage: 94.64 percent; required minimum: 90 percent. | ||
| - Four focused replay/concurrency tests passed after lifecycle fixture cleanup. | ||
| - Ruff, Markdown links, stale Workstream wording, stale authorization docs, and | ||
| diff integrity passed. | ||
|
|
||
| ## Test delta | ||
|
|
||
| Lifecycle audit tests were added; no existing test was removed, skipped, | ||
| weakened, or rewritten to accept broken behavior. Test cleanup now removes all | ||
| audit rows created by the fixture, including lifecycle compatibility rows. | ||
|
|
||
| ## CI integrity | ||
|
|
||
| No workflow, lane, runner, dependency, package script, coverage threshold, or | ||
| branch-protection behavior changed. Final hosted results pass: | ||
|
|
||
| - Agent Gates | ||
| - Backend `shared_foundations` | ||
| - Backend `schema_contracts_a` | ||
| - Backend `schema_contracts_b` | ||
| - Backend `project_lifecycle` | ||
| - Backend `task_lifecycle` | ||
| - merged Backend `test` | ||
|
|
||
| ## Reviewer results | ||
|
|
||
| Senior engineering, QA, security, product/ops, architecture, docs, | ||
| reuse/dedup, and test-delta tracks passed after valid findings were fixed. See | ||
| `WS-CON-001-02C-internal-review-evidence.md`. | ||
|
|
||
| ## External review | ||
|
|
||
| CodeRabbit passes. Actionable findings were addressed: concurrent replay is | ||
| atomic, committed lifecycle fixtures are cleaned up, the waiter assertion is | ||
| bound to the exact event lock, coverage evidence is precise, and initiative | ||
| status wording is current. | ||
|
|
||
| ## Remaining risks | ||
|
|
||
| - The participant uses fixed internal values in compatibility provenance columns; | ||
| future audit-schema cleanup may replace that compatibility representation. | ||
| - New lifecycle event tokens require an adopted feature contract, exact primary | ||
| entity, exact source references, and contract tests. | ||
| - REV/CON readers must not use nested audit `project_id` as authorization truth. | ||
|
|
||
| ## Follow-up work | ||
|
|
||
| After human merge, stop. REV-04B may consume this interface and merge after 02C. | ||
| CON-03C contribution/award persistence begins only under a separate explicit | ||
| instruction and after its REV-owned FK prerequisites exist. | ||
|
|
||
| ## Human review focus | ||
|
|
||
| - Is caller transaction ownership preserved with no hidden commit path? | ||
| - Are accepted, revision, contribution, and award lineage shapes exact? | ||
| - Does concurrent event-ID replay deterministically return or conflict? | ||
| - Is the shared audit module free of REV/CON feature-service coupling? | ||
|
|
||
| ## Human merge ownership | ||
|
|
||
| - [x] Required internal reviewers passed. | ||
| - [x] Hosted CI and CodeRabbit passed. | ||
| - [x] Valid external findings were addressed. | ||
| - [ ] The user explicitly approves PR #277 for merge. |
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.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Reconcile the reported coverage value.
Line 18 reports 95% coverage. The PR verification summary reports 94.04%. Record the exact value from the final coverage report.
🤖 Prompt for AI Agents