Repository navigation
fix(access): support ownership migration when enabling enforcement - #2304
happy-v587 wants to merge 21 commits into
Conversation
hidb4ai
left a comment
There was a problem hiding this comment.
Two reproducible ownership/recovery defects remain in the offline and external-store migration paths. Please address the inline findings before merging.
| access, | ||
| scopes, | ||
| owner=PrincipalRef(type=owner_type, id=owner_id), | ||
| transport="background", |
There was a problem hiding this comment.
[P2] Preserve recovery evidence in the offline migration too
This call omits owner_recovery, and the command always opens the built-in relationship store. On a stopped domain database containing a pending external-store Profile ownership intent for Alice, running access-ownership-migrate --action apply --owner user:bob --scope-id ... --maintenance-confirmed exits 0 with conflicts: [] and creates a local Bob owner. The original Alice intent remains pending; replaying it against that store then fails with artifact-owner. I reproduced this through the CLI using two SQLite databases. The HTTP protection does not cover this entry point. Inspect the persisted recovery evidence before assigning ownership, or reject deployments this offline command cannot safely migrate before making writes.
There was a problem hiding this comment.
Fixed in 15c9d93. The offline command now inspects durable ownership recovery evidence in the primary database before assigning an owner. Pending or completed external-store evidence returns a conflict and leaves local ownership untouched. CLI regressions cover both evidence states and verify that the original external owner remains recoverable.
There was a problem hiding this comment.
@happy-v587 Rechecked on 67cf2326955150110a27683b41be0d84a2faa346. The original built-in Profile case is fixed, but the new custom-family migration support exposes the same protection gap for incident-report.
[P2] Preserve custom-family recovery evidence in the offline path. An interrupted external HTTP migration to Alice leaves a durable pending owner intent. After stopping the Server, a fresh access-ownership-migrate --action apply --owner user:bob --scope-id ... --maintenance-confirmed process exits 0 with conflicts: [] and persists Bob locally. Alice's intent remains pending, and replay against that store fails with artifact-owner. Reproduced with the real example plugin, separate SQLite domain/relationship stores, and an independent CLI process; only external relationship delivery was fault-injected.
_owned_artifact_families() now includes saved custom declarations (ownership.py:401-403), but its recovery preflight calls OwnerRecovery.inventory_gaps(), which still filters on the process-local ARTIFACT_FAMILY_PROFILES. The offline process does not restore those custom profiles, so their recovery evidence is skipped. The recovery preflight must cover every persisted family accepted by migration before any competing ownership is written.
There was a problem hiding this comment.
Fixed in 0b39db6. Migration now passes the family set it accepted from persisted declarations into OwnerRecovery.inventory_gaps, and a family without a process-local profile reports its evidence instead of raising. Regression: tests/e2e/test_artifact_plugins.py::test_offline_migration_reports_pending_custom_family_owner creates an incident-report Artifact, stages a pending owner intent for Alice, runs server access-ownership-migrate --action apply --owner user:bob in a separate process, and asserts exit 1, conflicts == [owner-recovery-pending], and no Bob relation. Verified the test fails without the change (migration applies Bob, conflicts: []).
There was a problem hiding this comment.
head 0b39db6b 已按本条处置,补两处独立核对。
- 家族集合同源:
ownership.py的_owned_artifact_families取「内置OWNED_ARTIFACT_FAMILIES∪ 持久化的read_artifact_declarations」,plan 侧的_artifact_gaps(...)与离线 apply 侧调用的是同一个frozenset,新增的_owner_recovery_conflicts(..., families)把这同一集合传给OwnerRecovery.inventory_gaps。该函数随后不再回落到进程内ARTIFACT_FAMILY_PROFILES:传入families时用tuple(dict.fromkeys(families))构造IN条件,缺本地 profile 的家族走profile is None分支报证据而不是KeyError。离线进程没有插件 profile 时不会再写出与外部 intent 竞争的 owner。 release/upgrade-support.json的schema_review.persistence_sha256在本提交由2c22da66…变为e353cb45…,与server/authz/owner_recovery.py的改动同源(MANAGED_INPUTS含src/powercontext/server/authz)。我在 exact head 副本上用scripts/upgrade_release_gate.py::managed_digest复算,得到e353cb455c823180b0847f7b3b44fce5dcea8bb29d312eecc3f14e83c1e950de,与声明一致。
未覆盖:离线 access-ownership-migrate 对已注册自定义家族的真实重放我没有执行(需要带插件注册的 Server 实例与真实 Access 存储),该 head 的 86 success / 11 skipped 只覆盖既有 job。
There was a problem hiding this comment.
@happy-v587 Rechecked 2ee2da386b93e621404a96ac701233452ab19fc0: the custom Artifact pending/completed cases are fixed, but Candidate attribution still has this protection gap.
[P2] Cover every accepted Candidate family in recovery preflight. _candidate_gaps() accepts Prompt Dream Candidates, while ownership.py:314 now passes the Artifact ownership family set to the Candidate recovery scan too; that set excludes prompt. With a valid Prompt Candidate, interrupting external HTTP migration to Alice leaves a durable Candidate intent. Bob's HTTP dry-run then reports it in applied with no conflicts. After stopping the Server, a fresh access-ownership-migrate --action apply --owner user:bob --scope-id ... --maintenance-confirmed exits 0 and persists Bob's attestation; Alice's intent remains pending, and replay against that store fails with candidate-owner.
Reproduced using the SDK Dream path with deterministic generation, real SQLite stores, HTTP migration, and an independent CLI process; external relationship delivery was fault-injected. The unfiltered recovery scan sees Alice's intent, while the migration-filtered scan returns no items. Recovery protection must include every Candidate identity accepted by migration, even when its family does not require standalone Artifact ownership.
2ff6e32 to
87d7e1f
Compare
|
@happy-v587 please fix the file confliction |
hidb4ai
left a comment
There was a problem hiding this comment.
@happy-v587 Re-reviewed 1ca415f5. The previously reported ownership/audit and Windows-path defects are addressed. A merge probe against current master 90355b8e still reports conflicts in desktop/VALIDATION.md, desktop/src-tauri/src/transport/operations.json, desktop/ui/src/generated/operations.ts, and release/upgrade-support.json. Please integrate current master, regenerate the combined contracts, recheck the Desktop qualification and persistence digest, and complete Main, including the newly added Windows cases, before merging.
hidb4ai
left a comment
There was a problem hiding this comment.
@happy-v587 Re-reviewed cf6741eb. The previously reported ownership/audit and Windows-path defects are fixed, and the merge conflicts reported on 1ca415f5 are resolved. I found no further blocking defect in the reviewed ownership migration paths. The merged Desktop contract has a matching qualification record, and the persistence-policy declaration is consistent. Current-head Main and acceptance checks are still pending; please complete those, including the affected Windows cases, before merging.
hidb4ai
left a comment
There was a problem hiding this comment.
Two ownership-maintenance defects remain: the offline preview schedules processing work, and HTTP migration drops the originating audit context. Please address the inline findings before merging.
|
CI is complete on All six review threads are resolved. The PR has no merge conflicts. The earlier changes-requested review remains recorded; the fixes and their validation are ready for reviewer confirmation. |
hireview001
left a comment
There was a problem hiding this comment.
- Resolve merge conflicts with the target branch.
19994e2 to
7d1ad6d
Compare
|
Rebased onto Both P2 findings are fixed in
Desktop qualification was rerun for the rebased source: wheel |
|
CI triage for run 41256517755 (head 7d1ad6d): 90 checks pass; two failed and both are runner infrastructure, not branch behavior.
This account has pull-only rights on oceanbase/powercontext, so per-job rerun returns 403. Pushed 67cf232, an empty commit that only retriggers the workflow matrix; no file changed and the tree is identical to 7d1ad6d. |
hidb4ai
left a comment
There was a problem hiding this comment.
Re-reviewed commit 67cf2326955150110a27683b41be0d84a2faa346. The earlier background-dispatch and HTTP audit-identity issues are fixed. One confirmed P2 remains in the new custom-family support: a fresh offline migration can miss persisted owner-recovery evidence and assign a competing owner. See the reproduction and repair direction in #2304 (comment). Please address this before merging.
Co-Authored-By: Claude Code <noreply@anthropic.com>
The rebase rebuilt the merge commit from its parents, so manual merge resolutions that were not part of either parent were lost. Restore them: - Guard Linux-only peer-credential/socket constants in Source background process control for non-Linux type checking. - Accept the allow_missing_database keyword that the MySQL migration caller passes in the vector admission fixture. - Name the test database explicitly in the code publication fixtures, as the SeekDB store signature now requires. Co-Authored-By: Claude Code <noreply@anthropic.com>
Record sqlite-atomic-bfaff459-v1 for the bundled OpenAPI contract 4aeefdd6... and Server source bfaff45..., built from the clean rebased merge commit as powercontext-1.4.2.dev97+gbfaff4594-py3-none-any.whl (sha256 b8291955...). All 666 packaged runtime files match the recorded source bytes, and the real Server harness passed anonymous loopback, static Bearer, HTTPS with explicit CA/base path, and enforced-access provider modes on macOS ARM64, covering the eleven recorded protocol operations. The superseded 285620a record is removed. Historical records retain their original identities, operation sets and evidence. The bilingual guides now point users at the matching record. Co-Authored-By: Claude Code <noreply@anthropic.com>
Ownership migration only inventoried built-in families, so a registered custom family stayed ownerless and its revision writes stayed denied by ARTIFACT_WRITE. Inventories now include families from persisted plugin declarations. Scope- and Candidate-derived owner keys could exceed the Access limit of 255 characters. One bounded key builder keeps accepted spellings stable and digests longer identities, and every owner write site uses it. Co-Authored-By: Claude Code <noreply@anthropic.com>
The checked-in model order did not match the generator output for the resolved contract. Regenerate so make contract-test stays reproducible. Co-Authored-By: Claude Code <noreply@anthropic.com>
The previous record referenced a commit that no longer exists after the rebase. Rebuilt the wheel from 581be59, checked 667 runtime files byte-for-byte, reran the four SQLite modes, and recompiled the native probe with the locked toolchain. Co-Authored-By: Claude Code <noreply@anthropic.com>
The offline access-ownership-migrate process registers no custom Artifact family profiles. Its recovery preflight therefore inventoried only the built-in families and wrote a competing owner over a pending external intent for a registered custom family; replay then failed with artifact-owner. Migration now passes the family set it accepted from persisted declarations into the recovery inventory, and a family without a local profile reports its evidence instead of raising. Co-Authored-By: Claude Code <noreply@anthropic.com>
67cf232 to
0b39db6
Compare
|
Rebased onto master 22090cd and handled the P2 custom-family recovery finding in 0b39db6.
CI is running on 0b39db6. |
Merge master 5032075 with the ownership migration fixes. Regenerate API bindings and integration bundles from the combined OpenAPI contract, retain both sets of Desktop qualification records, and refresh the persistence compatibility review without removing either rationale. Co-Authored-By: Claude Code <noreply@anthropic.com>
Record four real SQLite Server connection modes for clean source f3a90b2 and the combined OpenAPI contract. Preserve all historical qualification identities and update both locale guides to the executed profile. Co-Authored-By: Claude Code <noreply@anthropic.com>
|
@happy-v587 I have approved this PR. please fix the file confliction. |
|
Conflicts are resolved on Main run 41289931395 completed successfully on this exact head: all 18 workflow jobs passed, including OceanBase acceptance. The PR shows 19 successful checks including CLA, with no pending or failed checks. This run's job selection is the evidence for this head; previous runs have separate matrix results. All eight review threads are resolved. GitHub still reports |
| # The checked background Principal does not inherit the administrator's groups. | ||
| context = replace(migration_context(PLAN_OPERATION, transport=transport, context=context), subject_groups=()) | ||
| for scope_id in selected: | ||
| decision = await access.check( |
There was a problem hiding this comment.
[P2] Account for static permissions in background checks
For fresh legacy Scopes in a single-token deployment, checking service:server-token reports a contribution denial even though the configured worker calls bootstrap_static_scope() before authorization and succeeds. Evaluate the worker's effective permissions, including its configured static preset, without granting bindings during planning.
There was a problem hiding this comment.
Fixed in e08cc47. Background planning includes the configured local static preset through a read-only Access check. It inspects preset receipts, so a revoked contributor remains denied; planning neither materializes Scope bindings nor grants administrator roles. Existing Profile write authority is still checked separately. HTTP regressions cover cold Scopes, own/other Profile owners, unrelated Principals, revocation, and unchanged grants; offline tests cover configured-token and no-token deployments. The new offline cases are selected by Windows CI. Local SQLite checks pass; the new remote run is separate.
There was a problem hiding this comment.
@happy-v587 Rechecked 2ee2da386b93e621404a96ac701233452ab19fc0: the static-preset fix works for ordinary Scope IDs, but the same false denial remains for supported long IDs.
[P2] Match static permission preview to actual bootstrap for long Scopes. On a cold 220- or 256-character Scope, /v1/access/ownership/plan reports service:server-token as denied with no-matching-binding. An immediate authenticated Source write succeeds with 201 through the real SQLite static bootstrap, and repeating the plan returns no gap. The new len(key) <= 255 guard in authz/service.py:923 rejects the generated preset key, whereas the bootstrap path it predicts successfully persists it. Align the read-only prediction with actual bootstrap behavior for supported identities, while retaining the revoked-receipt protection.
This was executed through real Server lifespan and HTTP ASGI with SQLite, not a mocked authorization provider or a spawned-worker/MySQL test.
|
@hireview001 @hidb4ai Please re-review current head The Handoff recovery-evidence gap, published-Handoff inventory gap, and static background-permission check are fixed. The static check also preserves revoked grants. All 11 review threads are resolved, with fix details and regression evidence in the relevant replies. Local ownership/authorization/recovery tests, contract checks, and The formal review-request action is unavailable to the current integration/account, so I am requesting re-review here. |
hidb4ai
left a comment
There was a problem hiding this comment.
Re-reviewed 2ee2da386b93e621404a96ac701233452ab19fc0. The previous custom Artifact and Handoff attribution cases are fixed. Two confirmed P2 cases remain:
- Prompt Candidate migration skips recorded owner-recovery evidence and can persist competing attribution: #2304 (comment)
- Static background permission preview falsely rejects supported long Scope IDs: #2304 (comment)
Please address these before merging.
Which issue or RFC does this PR close?
Closes #2299.
Rationale for this change
Data accepted with
ACCESS_MODE=disabledhas no Artifact owner or Candidate owner attestation. Enabling enforcement preserves reads but blocks old Artifact updates with403and Candidate approval with503 artifact_owner_pending. Administrators need explicit attribution and a check of the background Principal's permissions.What changes are included in this PR?
powercontext server access-ownership-migrateplan/apply, explicit ownership, Scope selection, maintenance confirmation, and a pre-switch--background-principalcheck.Are there any user-facing changes?
Administrators can preview and assign missing ownership before or after enabling enforcement. HTTP apply requires enforcement and
server.admin. Background checks without an Access store return an explicit unavailable error; the offline command supports this check before enforcement.Ownership assignments are immutable. Back up the database and select the correct Principal for each Scope before applying. Rolling back application code does not undo ownership assignments. The migration changes authorization metadata, preserves domain history, and uses the existing ownership recovery schema.
How was this change tested?
uv run --frozen pytest -q tests/e2e/test_access_ownership_migration.py tests/e2e/test_owner_recovery_http.py tests/test_owner_recovery.py tests/e2e/test_recall_manifest.py tests/e2e/test_atomic_memory_description_upgrade.py— 67 passed. These cover ownership migration, external recovery/audit retry, long identities, the merged manifest API, and description upgrades.make contract-test— 56 passed. Python, integration and Desktop artifacts were regenerated from the combined OpenAPI;pnpm --dir desktop generate:checkalso passes with the installed OpenJDK on PATH.UV_NO_SYNC=1 make check— passed, including lock checks, the combined persistence compatibility review, hooks, type checks and 61 integration-manifest tests.make js-test cindy-testwith Node 24.14.1 / pnpm 11.13.1 — passed, including 439 DSH unit tests, 9 DSH integration tests, 20 Cindy tests, package creation and committed-bundle drift checks.The existing
desktop/tests/real_server.pynative harness passed all four SQLite HTTP/TLS connection modes on clean Server sourcesdb9c8d6edc49166504b39e0d8038dd0082368dee. All 625 packaged runtime source files match that commit byte for byte, excluding generated version metadata. The immutable source/contract/wheel evidence is recorded underdesktop/VALIDATION.md#server-db9c8d6e-protocol-qualification; historical qualification records retain their original identities.Migration tests use temporary SQLite databases with fault-injected external relationship/audit delivery. Protocol qualification uses independent built-wheel Server processes on macOS ARM64. These results do not establish native Windows/Intel execution, installed Desktop UI/credential acceptance, seekDB/OceanBase upgrade acceptance or real spawned Worker migration acceptance. Windows CI retains the three offline path cases; new remote CI results are separate from local validation.
AI usage statement
Codex (GPT-6.1 and GPT-6 family models) assisted with implementation, code review, regression tests, documentation, and PR preparation. Validation commands and their results are listed above.