|
| 1 | +# ResourcePolicyUpdates within Authorization |
| 2 | + |
| 3 | +Accepted source contract: [ADR-093](../../ADR/ADR-093-resource-policy-updates.md). |
| 4 | +This closes the public metadata update gap exposed by AC-LINEAGE-004 without |
| 5 | +performing a physical resource, index, authority, quota or schema migration. |
| 6 | +Canonical feature ownership is Authorization. Existing ConfigureResource |
| 7 | +admission, persisted administrative authority, metadata RF3 and native outcomes |
| 8 | +remain the sole write path. |
| 9 | + |
| 10 | +`ConfigureResourceRequest` gains nullable `ExpectedSchemaVersion` at generated |
| 11 | +Orleans field ID3, omitted from public JSON when null. Null preserves create and |
| 12 | +identical-definition behavior and still rejects a changed existing definition. |
| 13 | +A non-null value is a compare-and-set on an existing resource. The replacement |
| 14 | +must increment SchemaVersion exactly once and may change only FieldPolicies and |
| 15 | +HeaderPolicies. All other definition properties must be canonically identical. |
| 16 | +No policy change may bypass the existing complete resource/path/budget validation. |
| 17 | +No-op version increments are invalid. Existing native aliases and IDs0–2 stay |
| 18 | +unchanged; older executors reject changed definitions rather than ignore policy. |
| 19 | + |
| 20 | +| Requirement | Acceptance and automated evidence | |
| 21 | +|---|---| |
| 22 | +| REQ-RPOL-001: authorized policy replacement is one canonical metadata commit | AC-RPOL-001: real ConfigureResource apply changes only policy arrays and advances the resource version; exact native persisted definition and original outcome survive reopen; owner data/vector/event bytes are unchanged. `ResourcePolicyUpdateTests` | |
| 23 | +| REQ-RPOL-002: concurrent/retried updates cannot restore stale authority | AC-RPOL-002: stale/missing expected version, missing resource, overflow, unchanged policy/version-only update, changed kind/domain/index/authority/quota/schema/paused state and malformed pointers fail with typed errors and no partial state; same original command retry reuses its receipt. `ResourcePolicyUpdateRejectionTests` | |
| 24 | +| REQ-RPOL-003: current reads reauthorize after policy ACK | AC-RPOL-003: projection reclassification, raw-field search denial, graph `/label` denial, and existing change-feed/live-query schema fences use the new persisted definition; old cursors cannot return cached sensitive payload. `EventProjectionPolicyTests`, `ResourcePolicyUpdateVisibilityTests` | |
| 25 | +| REQ-RPOL-004: public native clients and RF3 retain the trust boundary | AC-RPOL-004: SDK and official MCP ConfigureResource carry the CAS field through one request grain; current-policy queries on all replicas agree after ACK and fail closed after revocation/restart. `ResourcePolicyUpdateRf3Tests` | |
| 26 | + |
| 27 | +Ordered execution and task graph: |
| 28 | + |
| 29 | +1. Root approves this contract/ADR, owns request field, existing dispatcher join, |
| 30 | + public transport/schema inventory and architectural/status documentation. |
| 31 | +2. Luna query_wave owns new Core/Features/Authorization/Commands/ |
| 32 | + ResourcePolicyUpdates.cs plus new UnitTests/Features/Authorization/{Cases,Helpers} |
| 33 | + files and the existing EventProjection fixture's policy-update calls. Its |
| 34 | + helper validates the nullable prior/new definition and expected version; it |
| 35 | + owns no storage handles, routing, alternate authorizer or external side effect. |
| 36 | + The root invokes it after reading previous metadata and before any write. |
| 37 | +3. The helper distinguishes Validation (invalid/no-op increment), RevisionConflict |
| 38 | + (missing or stale CAS), UnsupportedCapability (physical/schema migration or |
| 39 | + legacy changed-definition request) and ResourceExhausted (version overflow). |
| 40 | + It cannot weaken the existing admin/tenant check or resource validation. |
| 41 | +4. Root reviews the complete diff and joins the helper, then builds the solution |
| 42 | + and runs the actual Aspire unit/scalar/recovery and SDK/MCP RF3 entries. Worker |
| 43 | + gates/Git are forbidden; no test run can race a shared binary replacement. |
| 44 | + In parallel, Luna lifecycle_wave owns only new IntegrationTests/Features/ |
| 45 | + Authorization/{Cases,Helpers,Assertions}/ResourcePolicyUpdate* files. It uses |
| 46 | + the actual SDK and official MCP client to qualify CAS, current read/use policy, |
| 47 | + old cursor rejection and healthy following requests against Aspire RF3. No |
| 48 | + shared fixture, transport, routing or production edits are delegated to it. |
| 49 | +5. Delivered-source Linux artifacts and every AC are required for closure. A |
| 50 | + local focused pass is development evidence only. |
| 51 | + |
| 52 | +Baseline: full local Aspire Unit36 on unchanged build36 source has3019/3165 |
| 53 | +passing and146 failures; policy reclassification is a diagnosed real product |
| 54 | +gap. No passing policy-update evidence exists yet. No packages or storage format |
| 55 | +change is required. SchemaVersion is already in text-generation and change-feed |
| 56 | +fences; store position invalidates committed RAM/cache cuts. Rollback disables |
| 57 | +new policy admission and retains the committed definition/version; it must never |
| 58 | +restore older policies or rewrite user data. Frontend N/A: existing admin API; |
| 59 | +SQL N/A for this stage: it does not advertise a new SQL management statement. |
| 60 | + |
| 61 | +```mermaid |
| 62 | +sequenceDiagram |
| 63 | + participant Caller as SDK or official MCP |
| 64 | + participant Request as Orleans request grain |
| 65 | + participant Meta as Canonical RF3 metadata owner |
| 66 | + Caller->>Request: ConfigureResource with expected version |
| 67 | + Request->>Meta: Persisted admin authorization and CAS |
| 68 | + Meta->>Meta: Validate policy-only replacement and commit |
| 69 | + Meta-->>Caller: New persisted definition and version |
| 70 | + Caller->>Request: Search or current page |
| 71 | + Request->>Meta: Current resource policy and version fence |
| 72 | +``` |
0 commit comments