Skip to content

docs(spec): per-subject claim names design for #358 - #543

Merged
pdettori merged 6 commits into
rossoctl:mainfrom
pdettori:fix/358-subject-claim-names
Oct 16, 2026
Merged

pdettori merged 6 commits into
rossoctl:mainfrom
pdettori:fix/358-subject-claim-names

Conversation

@pdettori

@pdettori pdettori commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Design spec for the second half of #358: per-subject PVC authorization on POST /workloads. Revised after review — see a0669ec.

The stop-gap from #350's review (claimName refused outright, so multi-user deployments lose bring-your-own-PVC entirely) is replaced by authorization by construction, with derivation and enforcement in Context Service: Moca forwards the caller's slug (workspace.claimName, validated like a workload name) with X-Context-Subject as today, and Context Service attaches moca-<scope>-<slug>, where <scope> is an HMAC of the subject under a Context Service secret. Alice naming data can never produce Bob's claim name, and the names are unguessable.

  • Needs a companion change in rossoctl/context-service (§2.2, in scope): accept storage.claimName, require the existing claim (409 claim_not_found, never provision one), never label it managed-by and never delete it on context delete — review-verified that none of that exists today (strict decoding, buildContextPVC always creates context-<name>, DeleteContext removes it)
  • The derived name comes back in the create response (attachment.claimName), is stored on the workload record, and is returned to its owner only — telling them exactly which PVC to pre-create
  • Moca-side derivation (the first draft) is recorded in §3's rejected list with the reasons; size/storageClass validation unchanged; the anonymous caller gets a stable scope like any subject
  • Closes MI1 §13's per-subject PVC bullet when implemented (the other half of /workloads: authorize caller-named PVCs per subject, and scope workload names #358, subject-scoped workload names, already shipped)

Spec: docs/specs/2026-10-15-per-subject-claim-names-design.md, registered in the milestone registry. Implementation follows on this branch.

Closes #358 (together with the implementation commits to follow).

🤖 Generated with Claude Code

Authorization by construction: Moca derives the claim name Context
Service receives from the calling subject (moca-<scope>-<claim>, the
stable recordScope hash), so a caller can only ever name claims inside
their own scope. Lifts the claim_name stop-gap with no mapping store
and no Context Service change.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
@pdettori pdettori added the ready-for-ai-review Request automated AI code review from clawgenti label Oct 16, 2026

@ingpaolodettori-dev ingpaolodettori-dev 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.

Summary

Design spec for #358's second half: derive the PVC claim name Context Service receives as moca-<recordScope(owner)>-<claim>, so a caller can only ever name claims in their own scope. The by-construction idea is sound and the moca-side facts check out against main 4c93f24 (recordScope at workloads.ts:75, NAME/MAX_NAME_LENGTH = 50, WORKSPACE_FIELDS, publicView returning workspace). Two blockers: the spec's premise that no Context Service change is needed doesn't hold (Context Service's create API has no caller-supplied claim at all), and the docs check is red because of a broken relative link.

Author: pdettori (MEMBER — maintainer)
Areas reviewed: Docs (spec + registry), cross-checked against moca main 4c93f24 and rossoctl/context-service main 7951826
Agent/IDE config (.claude/.vscode): none
Commits: 1 commit, all signed-off: yes
CI status: failing — docs (Check Markdown links); everything else green


Drafted with AI assistance (github-pr-review skill); reviewed by a maintainer before posting.

**Builds on (reuse, no redesign):** [MI1](2026-09-28-moca-multi-user-isolation-design.md)
(§4.3 records the stop-gap, §13 the deferral); the `/workloads` lifecycle
(`packages/knative-server/src/workloads.ts`: `recordScope`, `contextNameFor`, `WORKSPACE_FIELDS`);
[context-service](../../context-service.md) (Moca's client for Context Service's trusted,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

must-fix — this link resolves to <repo>/context-service.md, which doesn't exist (from docs/specs/, ../../ is the repo root), and it's the most likely cause of the red docs check (scripts/check-doc-links.py). The file is docs/context-service.md, so this should be ../context-service.md.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in a0669ec — ../context-service.md. scripts/check-doc-links.py passes locally now (191 files, 0 broken).

- The derived name is at most 88 characters (`moca-` + 32 hex + `-` + 50), well inside DNS-1123's
253, and matches its alphabet by construction.
- A caller can only ever produce names inside their own scope, so requirement 2 holds with nothing
to enforce elsewhere: no mapping store, no admin surface, no change to Context Service, no

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

must-fix — the claim that this needs "no change to Context Service" (and §2's "the derived name flows to Context Service unchanged") doesn't match Context Service today (rossoctl/context-service main 7951826):

  • contextresource.Storage has only backend, size, accessMode, storageClass. There is no claimName, and createContextAs (handler.go, used by POST /internal/v1/contexts) decodes with DisallowUnknownFields(), so storage.claimName gets a 400 invalid_request, which Moca surfaces as 502 context_service_error.
  • Even with the field accepted, buildContextPVC always creates a new PVC named contextPVCName(name) = context-<name>, labelled managed-by=context-service. GetContext/ListContexts only see PVCs carrying those labels, and context delete removes that PVC. There is no "attach an existing claim" mode.

So bring-your-own-PVC needs a Context Service change: accept an existing claim, adopt it without the managed labels or with a do-not-delete marker, and not delete it on DELETE /internal{ctx}. Otherwise mocactl workloads delete would destroy the user's pre-created volume, which contradicts §2's "a pre-created PVC is reused across workloads". Please move that into scope (and out of §3's rejected list), or say which Context Service release adds it. It also matters for §3's "Context-Service-side enforcement" trade-off: once Context Service has to change anyway, enforcing the scope there is cheaper than the spec suggests.

(Related: §1's "POST /workloads once forwarded a caller-supplied workspace.claimName" — whatever it forwarded, the current Context Service would refuse it. Worth checking what that path actually did.)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified all three points against context-service main 7951826 (Storage fields, DisallowUnknownFields at handler.go:329, buildContextPVC/resources.go:12,35, DeleteContext/manager.go:190-221). Revised in a0669ec:

  • The Context Service change is in scope as §2.2: accept storage.claimName, require the existing claim (409 claim_not_found, never provision one), no managed-by label, and DELETE never removes a caller-named claim — which is also how acceptance 5 (workloads delete must not destroy the pre-created volume) is pinned.
  • Since a CS change is unavoidable either way, derivation and enforcement moved there too (moca-<HMAC(secret,subject)>-<slug> under a CS-held secret), per your point that enforcing there is cheaper once it must change anyway. Moca now only passes the slug through and stores/returns the derived name from the create response (Resource.Attachment.ClaimName already exists for that view). Moca-side derivation is moved into §3's rejected list with the reasons (needs a cross-replica-stable secret that MOCA_CONTEXT_CACHE_SECRET explicitly is not — random per process when unset; names stay guessable where it's unset).
  • The companion work is recorded as to-be-tracked in rossoctl/context-service (§5); no release yet adds it.
  • On the parenthetical: e3abc55 did forward claimName, and the stop-gap (3418494) removed it; whether the then-current Context Service honored the field, §1 now says "forwarded toward" and cites both commits.

- The derived name is opaque. Whoever pre-creates the PVC — an operator, or a user with namespace
access — must obtain it from the owner's `GET /workloads/{id}`. That is the price of the mapping
not existing.
- A caller with rights to create PVCs in the Context Service namespace could plant a PVC under

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion — recordScope is an unkeyed sha256(owner)[:32], so anyone who knows (or can guess) a subject string, such as an email or GitHub login, can compute that user's derived names. The planting case then doesn't need the victim to reveal anything: someone with PVC-create rights pre-creates moca-<sha256(bob)>-data with their own contents, and Bob's workload runs on it. You argue such a caller is already privileged, which is fair. But PVC-create rights don't imply pod-create rights, and an HMAC keyed with a deployment secret (the way MOCA_CONTEXT_CACHE_SECRET keys cache names) would make the names unguessable at no extra cost. Worth at least stating the trade-off here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed structurally in a0669ec rather than as a stated trade-off: with derivation moved into Context Service, the scope is an HMAC under a Context Service secret, so the derived names are unguessable — not merely awkward to guess. The PVC-create-rights-not-implying-pod-create-rights point is kept in §3's limits.

…soctl#543 review

Verified against rossoctl/context-service main 7951826: Storage has no
claim field, createContextAs decodes strictly, buildContextPVC always
creates context-<name> and DeleteContext removes it — so 'no Context
Service change' was wrong and attach-existing-claim is needed there
regardless. Derivation and enforcement now live in Context Service
(moca-<HMAC(secret,subject)>-<slug>), which also makes the names
unguessable; Moca passes the slug through, validates and stores the
derived name from the create response, and returns it to its owner.
Also fixes the broken ../../context-service.md link (the red docs
check) and the §1 history.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>

@ingpaolodettori-dev ingpaolodettori-dev 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.

Follow-up review at a0669ec (incremental over 0f0cbe6).

All three of our earlier items are resolved: the link is ../context-service.md and docs is green. Context Service's companion change is in scope (§2.2). Derivation now uses a keyed HMAC under a Context Service secret, so names can't be guessed. Moving derivation into Context Service makes sense, and the moca-side facts check out against main 4c93f24: sendFailure passes 409s through, createContext spreads storage, and e3abc55 and 3418494 are real.

One blocker remains, in the §2.2 contract. Context Service has no Context record apart from its managed PVC. Labels and annotations on that PVC hold the name, revisions, frozen state, grants, consumers and audit, and contextId is the PVC UID. So "caller-owned, unlabelled claim; the record carries the attachment" needs a new home for Context metadata, plus a rule for one claim backing several Contexts. Details are inline, checked against rossoctl/context-service main 7951826.

Author: pdettori (MEMBER — maintainer)
Areas reviewed: Docs (spec), cross-checked against moca main 4c93f24 and rossoctl/context-service main 7951826
Agent/IDE config (.claude/.vscode): none
Commits: 2 commits, all signed-off: yes
CI status: passing (all checks green)


Drafted with AI assistance (github-pr-review skill); reviewed by a maintainer before posting.

a volume. `size` and `storageClass` are ignored on that path.
2. The claim is **caller-owned, not Context-Service-managed**: no `managed-by=context-service`
label is applied, and `DELETE /internal{ctx}` removes the Context but never the claim
(acceptance 5). The Context's record carries the attachment — `Resource.Attachment.ClaimName`

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

must-fix — this assumes a per-Context record that Context Service doesn't have. At main 7951826 a Context is its managed PVC, and every piece of Context state lives on that object:

  • the name and type come from the context.rossoctl.io/name and /type labels;
  • current revision, revision history and frozen revision are annotations (manager.go, PublishContextRevision);
  • the owner and grants (context.rossoctl.io/access-grants), consumers and audit events are annotations too (access.go);
  • Attachment.ClaimName isn't stored at all. resourceFromContextPVC derives it from pvc.Name at read time (manager.go:131);
  • GetContext, PublishContextRevision, deleteContext, contextPVC and the snapshot, clone and restore paths all look up contextPVCName(name) and require managed-by=context-service;
  • the trusted contextId Moca pins on (workloads.ts:289, checked at :359) is StorageUID, the PVC's UID (uploads.go:186).

So "no managed-by label, get and list don't depend on PVC labels" needs a new place for Context metadata: a ConfigMap, a CR, or similar. The other option is writing annotations onto a PVC the caller owns, but then anyone with edit rights on that PVC can rewrite its grants. Please say which one the companion change uses. It's most of the Context Service work, not a detail.

The spec also needs to say what happens when one claim backs two Contexts, e.g. Alice creates two workloads that both name data. With PVC-backed metadata they'd share revisions, frozen state and contextId. Then delete-and-recreate over the same claim keeps the same UID, which weakens the identity pin on freeze. Either refuse it (e.g. 409 claim_in_use) or define a contextId that isn't the claim's UID.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specified in df9d7a7, §2.2 items 1–3 — and agreed it is most of the work, not a detail; the current-state facts you list are now the section's opening paragraph so the contract is readable against them.

  • Metadata home: a per-Context ConfigMap record for attached-claim contexts (the existing queryIndexName pattern), carrying name, type, revision history, frozen revision, owner, grants, consumers, audit and the attachment. Revision history and audit keep their present PVC-annotation bounds; a CR is the recorded escape hatch if they outgrow a ConfigMap's 1 MiB. Writing annotations on the caller's PVC is rejected for the reason you give — anyone with edit rights on the claim could rewrite its grants. Managed-PVC contexts keep PVC-carried metadata untouched, so the change stays additive; unifying the two homes is left to a later Context Service refactor.
  • contextId = the record's UID, never the claim's (shared across contexts, stable across delete-recreate — it cannot carry the identity Moca pins on). Upload, freeze and export verify their expected UID against the record where they verify pvc.UID today (context_upload.go); Moca's pin logic at workloads.ts:359 is unchanged.
  • One claim, one live Context: 409 claim_in_use. Delete releases the claim, and the re-created Context's fresh record has a fresh UID, so the freeze pin stays meaningful.

label is applied, and `DELETE /internal{ctx}` removes the Context but never the claim
(acceptance 5). The Context's record carries the attachment — `Resource.Attachment.ClaimName`
already exists for exactly this view — so get and list do not depend on PVC labels.
3. The create response's `attachment.claimName` carries the derived name, which is how Moca (and

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion — the trusted create response deliberately doesn't carry an attachment today. trustedContext in internal/api/uploads.go:106 says it "omits the PVC attachment because Moca receives content as bundles, not mounts", and Moca's TrustedContext doc says the same (context-service.ts:13). So attachment.claimName in the create response is a new field on the trusted contract, not something that's already there. Please list it as one of §2.2's changes and update that rationale.

Related: since the trusted path delivers content as bundles (upload → freeze → sandbox delivery, which §2.3 says stays untouched), it's worth one sentence on what "runs on that claim's volume" (acceptance 1) means here. Does the uploaded bundle land in the caller's pre-created PVC, and what happens to whatever was already on it?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both addressed in df9d7a7.

  • attachment.claimName is now §2.2 item 6, as an explicit change to the trusted contract, with the uploads.go:106 rationale amended rather than dropped: the trusted view still omits the PVC attachment, except the derived claim name for an attached-claim Context, because Moca stores it and returns it to the owner — the only attachment field on the trusted path. Moca's TrustedContext doc comment gets the mirror amendment.
  • "Runs on the claim's volume" is pinned by §2.2 item 5, against the mechanics you checked: the upload helper mounts the claim at /workspace and materializes the bundle onto it, revisions are computed from it, export streams from it — so the revision the workload runs is the one stored on the caller's claim. What happens to what was already on it: it stays and joins the first revision's baseline (that is the point of bringing your own volume), and paths colliding with the uploaded bundle are overwritten. §3's limits state the trust plainly: the only subject who can name the claim is its owner, so there is deliberately no protection from adoption.

Service**, not Moca, derives the claim it attaches:

```
moca-<scope>-<claim> where <scope> = HMAC-SHA256(secret, subject)[:32]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit — contextresource.Subject is {kind, name}, so please pin the HMAC input encoding (e.g. kind + ":" + name, the way subjectKey does in access.go:315). Otherwise a user:x and a serviceaccount:x could share a scope, and any reimplementation could derive different names.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pinned in df9d7a7, §2.1: the HMAC input is subjectKey — kind + ":" + name, the encoding access.go:315 already uses — so user:x and serviceaccount:x never share a scope and reimplementations derive the same names. Moca's callers are user:<owner>, the same string X-Context-Subject carries today.

…texts

Follow-up review of rossoctl#543: Context Service has no Context record apart
from its managed PVC (labels, annotations, contextId = PVC UID), so
'caller-owned unlabelled claim' needs a metadata home. The companion
contract now specifies: a per-Context ConfigMap record for attached
claims (PVC annotations rejected — claim editors could rewrite grants),
contextId = record UID with freeze/export verifying against it, one
claim per live Context (409 claim_in_use), the claim adopted as the
Context's filesystem with pre-existing content joining the first
revision, and attachment.claimName as an explicit new trusted-contract
field. The HMAC input is pinned to subjectKey (kind:name).

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
The lint hook's prettier pass normalizes *emphasis* to _emphasis_;
commit its rewrite so CI is green.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>

@ingpaolodettori-dev ingpaolodettori-dev 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.

Follow-up review at e4cba47 (incremental over a0669ec).

All three items from our a0669ec review are addressed in df9d7a7. §2.2 names the metadata home: a per-Context ConfigMap record, with PVC annotations rejected for the right reason. contextId is the record's UID, 409 claim_in_use covers one claim backing two Contexts, attachment.claimName is an explicit new trusted-contract field, and the HMAC input is pinned to subjectKey. 0459d4d fixes the Prettier _is_ emphasis, so lint is green again. e4cba47 links rossoctl/context-service#59 as the tracker.

One blocker remains. §2.2 item 5 doesn't match how Context Service stores revisions: uploads land in a content-addressed .context-service/materialized/<digest>/ directory, and export streams only that directory. So content already on an adopted claim never becomes part of a revision. context-service#59 copies the same text. The inline comment has the details.

There's also one suggestion on atomic uniqueness for claim_in_use and Context names now that there are two metadata homes.

Author: pdettori (MEMBER — maintainer)
Areas reviewed: Docs (spec), cross-checked against rossoctl/context-service main 7951826 (still its head)
Agent/IDE config (.claude/.vscode): none
Commits: 5 commits, all signed-off: yes
CI status: passing (all checks green; check was still pending when drafted)


Drafted with AI assistance (github-pr-review skill); reviewed by a maintainer before posting.

5. **The claim is adopted as the Context's filesystem, exactly as a managed PVC is today.** The
upload helper mounts it at `/workspace` and materializes the bundle onto it; revisions are
computed from it; export streams it back for sandbox delivery — so the revision a workload runs
is the one stored on the caller's claim. Whatever was already on the claim stays and joins the

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

must-fix: the upload mechanics in this item don't match what Context Service does (still true at context-service main 7951826, which is also the main the spec cites):

  • materializeUploadWithLimit (cmd/context-service/main.go:210) imports the bundle into staging under <mount>/.context-service/materialized/. It computes revision.Digest from the bundle's content, then renames staging to materialized/<digest>/ (:246). UploadContext refuses any result whose WorkspacePath isn't exactly .context-service/materialized/<revision> (internal/kube/context_upload.go:164).
  • exportMaterializedRevision (main.go:114) streams only materialized/<revision>/, and ExportFrozenContext checks it against the frozen revision.

So on an adopted claim, content already at the root is never part of any revision, never exported, and never delivered to the sandbox. "Paths that collide are overwritten" doesn't happen either, because the bundle lands in its own content-addressed directory. Making pre-existing content "join the first revision's baseline" would break the property the freeze pin relies on: today the revision ID is the digest of exactly what export streams.

Please rewrite item 5 to say one of these:

  • (a) the claim is only a revision store. Pre-existing content is ignored, and Context Service touches only .context-service/ on it. Under this option, acceptance 1, the §3 "Adoption is trust" limit (line 184) and the §4 test on line 209 change to match. Add one sentence on what BYO-PVC then buys the caller (capacity or storage class, not data).
  • (b) a new "import the existing tree as a revision" operation that digests and materializes the root content as its own revision. That's a further companion change, and it needs its own size and type checks (contextUploadExpandedLimit, the bundle-type check).

rossoctl/context-service#59 copies this item (item 5 and its last test bullet) word for word, so it needs the same edit.

A smaller point under either option: ensureMaterializationDirectory chmods .context-service/ and materialized/ to 0755 on the caller's volume, and the expanded-size limit comes from the claim's requested size, not its free space. Both are fine on a managed PVC, but on an adopted one they're worth a line.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rewritten in 2c9273f, option (a) — verified against materializeUploadWithLimit (main.go:210, staging rename to materialized/<digest>/ at :246), UploadContext's WorkspacePath check (context_upload.go:164) and exportMaterializedRevision (main.go:114) before choosing. §2.2 item 5 now says: the claim is a revision store exactly as a managed PVC — uploads materialize content-addressed under .context-service/materialized/<digest>/, the revision id is the digest of exactly what export streams, and export streams only that directory, so the freeze pin's property is unchanged. Pre-existing content is invisible (never read, part of a revision, exported, or overwritten); Context Service touches only .context-service/; BYO-PVC buys capacity, storage class and placement, not data. Acceptance 1 was already phrased as "the revision the workload runs is the one stored on the caller's claim," which survives; the §3 limit and the §4 test bullet are rewritten to match, and option (b) — importing the existing tree as its own revision, with contextUploadExpandedLimit and the bundle-type check — is recorded as deliberately not built. The chmod-0755 and requested-size-not-free-space footnotes are both in the item, and the same edits are mirrored into rossoctl/context-service#59.

cannot carry the identity Moca pins on. Upload, freeze and export verify their expected UID
against the record (today they verify against `pvc.UID`, `context_upload.go`); Moca's pin logic
is unchanged — it compares the `contextId` Context Service answers with.
3. **One claim backs at most one live Context:** a create naming a claim an attached Context

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: with two metadata homes, both uniqueness rules need an atomic key, and the spec should say which one.

  • Today Context name uniqueness comes for free from PersistentVolumeClaims.Create on context-<name> (manager.go:72, where IsAlreadyExists maps to ErrAlreadyExists). An attached-claim Context's record is a different object, so a managed create and an attached create with the same name could both succeed unless one shared object reserves the name.
  • claim_in_use has the same race. A list-then-create check can't refuse both of two concurrent creates that name the same claim.

One way to do it is deterministically named objects created with create-if-absent semantics: the record keyed by Context name (so it collides with the managed path's reservation), plus a per-claim marker or a record name derived from the claim. Delete then has to remove both before the claim counts as released. This applies to context-service#59 items 1 and 3 as well.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adopted in 2c9273f, §2.2 items 1 and 3, along your lines: the record is deterministically named for the Context name and created with create-if-absent semantics, and the managed path creates the same reservation before its PVC (today uniqueness comes free from PersistentVolumeClaims.Create on context-<name>, manager.go:72) — so a managed and an attached create of one name cannot both succeed. claim_in_use is a per-claim marker object, deterministically named from the claim and created if-absent, and delete removes the record and the marker before the claim counts as released. The §4 test bullet adds both races: two concurrent creates naming one claim, and a managed/attached pair on one Context name — exactly one winner each. Mirrored into rossoctl/context-service#59 items 1 and 3.

Follow-up review of rossoctl#543: uploads land content-addressed in
.context-service/materialized/<digest>/ and export streams only that
directory, so pre-existing content on a claim never joins a revision and
the freeze pin's digest property is what must be preserved. Item 5 now
states that (bring-your-own-PVC buys capacity, storage class and
placement, not data), records the chmod and requested-size footnotes,
and defers importing the existing tree as a revision. Items 1 and 3
specify the atomic keys: a shared name reservation across both metadata
homes, and a per-claim marker created if-absent for claim_in_use.
Mirrored into rossoctl/context-service#59.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>

@ingpaolodettori-dev ingpaolodettori-dev 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.

Follow-up review at 2c9273f (incremental vs e4cba47, the head of our previous REQUEST_CHANGES).

Both items from that review are resolved:

  • must-fix (item 5 upload mechanics): fixed with option (a). The claim is now a revision store, and uploads materialize content-addressed under .context-service/materialized/<digest>/. The "revision id = digest of exactly what export streams" property is preserved, and BYO-PVC is stated to buy capacity, storage class and placement, not data. The §3 limit and the §4 test are rewritten to match, option (b) is recorded as deliberately not built, and the chmod-0755 and requested-size footnotes are in the item. I checked this against context-service main 7951826 (materializeUploadWithLimit, UploadContext's WorkspacePath check, exportMaterializedRevision).
  • suggestion (atomic keys): adopted. Items 1 and 3 now give a shared create-if-absent name reservation across both metadata homes, plus a per-claim claim_in_use marker. Delete removes both, and §4 tests both races.

One new non-blocking suggestion (inline): a pre-existing .context-service/ tree on an adopted claim isn't "invisible". It is verified and reused, and it survives Context delete. One sentence would turn that into a stated decision.

Author: pdettori (MEMBER — maintainer)
Areas reviewed: Docs (design spec + specs README)
Agent/IDE config (.claude/.vscode): none
Commits: 6 commits, all signed-off: yes
CI status: passing

(`exportMaterializedRevision`), and export streams only that directory. So the revision a
workload runs is the one stored on the caller's claim, and the freeze pin's property — the
revision id is the digest of exactly what export delivers — is unchanged. Pre-existing content
at the claim's root is invisible: never read, never part of a revision, never exported, never

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: "Pre-existing content at the claim's root is invisible: never read, never part of a revision, never exported, never overwritten" holds for the root, but not for a .context-service/ tree that is already on the claim. At context-service main 7951826, materializeUploadWithLimit adopts that tree:

  • If materialized/<digest>/ already exists, it is reused after verifyMaterializedRevision (main.go:328) instead of being written fresh. If the existing copy doesn't match, or has a non-0755 dir or a bad file mode, every upload of that bundle fails with "existing materialized revision does not match uploaded content" until someone cleans the claim.
  • cleanupUploadStaging (main.go:284) deletes any .context-import-* entries it finds there.

On a managed PVC this can't come from anyone else. On an adopted claim it's the normal case once the claim is reused: DELETE removes the Context but never the claim (acceptance 5), so a deleted Context's materialized/ revisions stay. A later Context on the same claim inherits them, and nothing ever garbage-collects them. They also aren't counted against the requested-size limit, which is per upload.

None of this weakens the pin, because a reused revision is digest-verified. It's worth a sentence so it's a decision: a pre-existing .context-service/ is adopted (verified and reused, otherwise the upload fails), and revisions outlive their Context on a BYO claim. Also say whether delete should prune the Context's own materialized/ revisions or leave them to the owner. Put the same sentence in the "touches only .context-service/" phrasing in §3 (line 198) and in the §4 test bullet (line 227), and in context-service#59 item 5.

@pdettori
pdettori merged commit adec420 into rossoctl:main Oct 16, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-ai-review Request automated AI code review from clawgenti

Projects

None yet

Development

Successfully merging this pull request may close these issues.

/workloads: authorize caller-named PVCs per subject, and scope workload names

2 participants