feat(updates): per-tenant self-update policy for Werkpilot #149
Open
sharang
wants to merge 1 commits from
feat/update-policy into main
pull from: feat/update-policy
merge into: platform:main
platform:main
platform:feat/einstieg-plan
platform:feat/telemetry-relay
platform:feat/feedback-endpoint
platform:feat/onprem
platform:feat/onprem-mail
platform:feat/onprem-directory-users
platform:feat/onprem-mode
platform:feat/avv-autofill
platform:feat/release-avv-1.0.0
platform:fix/erpsetup-dunning-and-small
platform:feat/module-user-count
platform:feat/usage-summary
platform:feat/mahnung-ladder
platform:fix/toms-status-available
platform:feat/contractdocs-agb-tom
platform:feat/company-rules
platform:feat/staff-brand-slug
platform:fix/intake-outlives-purge
platform:fix/catalogue-labels
platform:feat/trial-offer-status
platform:feat/function-holders
platform:feat/assignable-bundles
platform:feat/contract-documents
platform:feat/erp-lb-versions
platform:feat/store-merges-unterlagen
platform:feat/product-hierarchy
platform:feat/preview-grants
platform:ci/platform-image-and-webhook
platform:ci/registry-meghsakha-orca-webhook
No Reviewers
Labels
Clear labels
cra:annex-i
cve
pruefwerk
risk:accepted
severity:critical
severity:high
severity:low
severity:medium
CRA Anhang I, wesentliche Cybersicherheitsanforderungen / CRA Annex I
Bekannte Schwachstelle in einer Abhängigkeit / known vulnerability in a dependency
Befund aus Prüfwerk / Prüfwerk finding
Risiko akzeptiert, nicht behoben / accepted risk, not fixed
Schweregrad kritisch / critical
Schweregrad hoch / high
Schweregrad niedrig / low
Schweregrad mittel / medium
No labels
Milestone
No items
No Milestone
Projects
Clear projects
No projects
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: platform/tenant-registry#149
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
What
The registry half of controlled self-update (platform/werkpilot#89). A workspace sets a per-product update policy, and the CLI receives it with every grant and heartbeat:
auto: the default, also when nothing is saved;off;a pinned release version.
Setting:
GET/PUT /v1/tenants/{id}/products/{product}/updateswith{"policy": "auto" | "off" | "<semver>"}.Flag: an
updatesstring in the grants ofPOST /v1/licencesandPOST /v1/licences/ci, in a heartbeat'srenewedgrant, and at the top of the heartbeat answer next tostatus.Why
Refs platform/werkpilot#89. The user chose a registry setting that lets a tenant turn updates off or pin them, carried to the CLI the same way as the telemetry flag (#148).
Linked milestone: n/a (werkpilot#89)
How
Setting
updateskey of the product'stenant_product_settingsdocument (0025), so no migration. The PUT reads the document, sets the key and writes it back; other keys survive (tested withtelemetryand an unrelated key).werkpilot; others get 404 on GET and PUT. The Prüfwerk settings PUT replaces its whole document, so the key must never land there.{"policy": …}, else 400invalid_input. The policy isauto,off, or a version matching the semver.org 2.0.0 regex, at most 64 characters. That means novprefix, no ranges (^,~,>=,a - b,||), no wildcards (x,*), no leading zeros, no surrounding whitespace, and no other words (latest,on,Auto).{tenant_id, product, policy, updated_by, updated_at}.FORBIDDEN_ROLE; another workspace gets 404). Services read withtenants.readand write withtenants.write; the portal calls as its service client.product_settings.changed(setting: updates, old, new), the same shape as the Prüfwerk and telemetry settings. A save that changes nothing writes nothing.Flag
updatesis always present and is a plain JSON string, not a JWT claim; the CLI applies it.autofor products without the setting (e.g. a firmwerk CI grant) and on the heartbeat's revoked or unknown-tenant answers.autoand a warning is logged; the licence call doesn't fail.Deviations from the issue: none in the contract. Two things the issue left open:
1.0.0+build.5), because semver 2.0.0 allows it.autois stored: settingautostores"auto"rather than removing the key; both read asauto.Overlap with #147 (feedback) and #148 (telemetry): no identifiers are shared. The text overlaps in places:
licenceRespandheartbeatRespfields sit at the same spot as #148'stelemetryfields, inlicences.go,licences_ci.go, the route block inserver.go, and theLicenceIssued/LicenceHeartbeatschemas and the path list inopenapi.yaml.authz_testandopenapi_testcase lists.Whichever merges later resolves these by keeping both sides.
Test plan
update_policy_test.go, througheachStore, so CI's Postgres run covers it):auto;0.4.0-rc2, the old licence's heartbeat, a new grant and the werkpilot CI grant carry it, while firmwerk's CI grant staysauto;off, a heartbeat past half-life renews and both the top level and the renewed grant sayoff;auto.product_settings.changedevents for 3 changes, with the right old and new values. The repeated save writes nothing.vprefix, short or long versions, leading zeros, a dangling-or+, whitespace, ranges, wildcards and over-long versions. Valid pins are accepted, including0.3.1,0.4.0-rc2,1.0.0-alpha.1,1.0.0+build.5and10.20.30. Other products give 404 on GET and PUT, and an unknown tenant gives 404. Other document keys are preserved.update_policy_scope_test.go): USER, CXO and FINANCE get 403 on GET and PUT, another workspace's admin gets 404, and IT_ADMIN and OWNER pass. The policy changes only on an allowed PUT. The audit event names the admin (actoru-1, typeuser).authz_testroute groups andopenapi_testroute cases.gofmt -l .clean,go vet ./...clean,golangci-lint run(v2.12.2) 0 issues, andgo test -race -count=1 ./...green.eachStorePostgres variants skipped locally because Docker isn't reachable here, so they run only in CI. Only the existingGetTenantProductSettings/PutTenantProductSettings/AppendAuditare used.Risk
Blast radius: licence answers gain one field, which old clients ignore. The setting does nothing until an admin changes it, and the CLI applies it.
What could break: each licence issue and heartbeat does one more settings read. A read error falls back to
autoand is logged; it does not fail the call.Rollback plan: set the policy back to
auto, or revert the PR and redeploy.Checklist
product_settings.changed)featureFlags.evaluate()used for any toggleable behavior: n/a, the policy is stored tenant dataScreenshots / recordings
n/a (no UI; the portal toggle is a follow-up)
🤖 Generated with Claude Code
https://claude.ai/code/session_01Q9inRayW7ztyk1uAtwMJPR
A workspace can leave Werkpilot's self-update on ("auto", the default), turn it off, or pin a release version. - GET/PUT /v1/tenants/{id}/products/{product}/updates with {"policy": "auto" | "off" | "<semver>"}: the "updates" key of the product's settings document (0025, no migration); IT_ADMIN/OWNER or services; audited as product_settings.changed; werkpilot only - "updates" in licence grants (POST /v1/licences, /v1/licences/ci, heartbeat renewals) and at the top of the heartbeat answer, read fresh each time, "auto" when unset Refs platform/werkpilot#89 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q9inRayW7ztyk1uAtwMJPRView command line instructions
Checkout
From your project repository, check out a new branch and test the changes.