Activate: accept the observed app version token
directory.activate-consumer's app_version now accepts the version Alta observed at the instance's /api/version (^[A-Za-z0-9][A-Za-z0-9._+-]{0,127}$, e.g. git describe output) instead of only a 40-hex commit, per amendment s2 item 6 (the evidence is what Alta observed). Nothing else in activate changes; the value is never stored or compared after the shape check. Tests cover describe strings, 40-hex, bounds and refusals end to end. Docs updated (team-provisioning-app s7, amendment s2/s13). Reviewed by Claude Fable 5.1 (claude-fable-5-1), discussion 96, APPROVED; CI green at 520003f.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Squashed from activate-observed-version into main.
4 files changed,
+92
−15
implementation/team-provisioning-amendment.md+14 −1implementation/team-provisioning-app.md+9 −2internal/operator/verification.go+10 −11internal/operator/verification_test.go+59 −1
CI passed — run details
diff --git a/implementation/team-provisioning-amendment.md b/implementation/team-provisioning-amendment.md| index 60bdf77..0d6c263 100644 |
| --- a/implementation/team-provisioning-amendment.md |
| +++ b/implementation/team-provisioning-amendment.md |
| @@ -89,7 +89,10 @@ Each quoted file carries a one-line pointer here (added when slice 1 landed). |
| attestation."* — **Weakened, said so:** on this path |
| `ActivationEvidence` is Alta's signed observation through the CARLOS |
| console plus the credential role's registry digest |
| - (`team-provisioning-app.md` §7), not a platform attestation. |
| + (`team-provisioning-app.md` §7), not a platform attestation. Its |
| + `app_version` is therefore the opaque token Alta read on `/api/version` |
| + (bounded printable ASCII, `^[A-Za-z0-9][A-Za-z0-9._+-]{0,127}$`), not a |
| + 40-hex commit Home could treat as attested (§13, Alta review). |
| 7. `roster-contract.md`: *"This module … adds no public bootstrap route and |
| no runtime operator mutation transport. Live provisioning/restore remains |
| gated on supported fenced maintenance (platform discussion117) or a |
| @@ -599,6 +602,16 @@ review's ruling: |
| `setConsumerPolicy` may only add one registered consumer to form-action. |
| **Accepted.** |
| +**Alta review (oficina/alta discussion 1, Claude Fable 5.1, mismatch ruling |
| +5).** `directory.activate-consumer` required `app_version` to be a 40-hex |
| +commit, a leftover of the platform-attestation design that item 6 of §2 |
| +already weakened: every app's `/api/version` answers `git describe --tags |
| +--always`, so no team instance could be activated. `version()` now admits |
| +the observed token, `^[A-Za-z0-9][A-Za-z0-9._+-]{0,127}$`; the field's name, |
| +type and canonical encoding, and every other activation check, are |
| +unchanged. Rejected: stamping 40-hex into each app's Makefile, which takes |
| +away the human version Paul reads on `/api/version` to confirm a deploy. |
| + |
| **For a later amendment (design note, not a deviation):** |
| `credential.retire-consumer` is app-scoped, not team-scoped — the credential |
| role sees no labels — so a confirmed `retire-apps` window admits retiring any |
diff --git a/implementation/team-provisioning-app.md b/implementation/team-provisioning-app.md| index 3b97244..e74e5b2 100644 |
| --- a/implementation/team-provisioning-app.md |
| +++ b/implementation/team-provisioning-app.md |
| @@ -233,8 +233,15 @@ call at that point. |
| `ActivationEvidence` fields, with their encodings (`verification.go`): |
| -- `app_version` — the 40-hex commit in `/api/version`'s body; an app |
| - reporting anything else cannot be activated until it does. |
| +- `app_version` — the token in `/api/version`'s body, exactly as Alta read |
| + it: every app stamps `git describe --tags --always` |
| + (`v0.1.0-63-gd867db1`, or a bare commit). Home admits any opaque, |
| + bounded, printable-ASCII token, `^[A-Za-z0-9][A-Za-z0-9._+-]{0,127}$`, |
| + and checks nothing more (`verification.go` `version()`). It was a |
| + 40-hex commit until Fable's Alta review (oficina/alta discussion 1, |
| + mismatch ruling 5) ruled that a leftover of the platform-attestation |
| + design; stamping 40-hex into the apps instead was rejected, since it |
| + takes away the human version Paul reads to confirm a deploy. |
| - `artifact_digest` — base64url (no padding) of SHA-256 over the exact |
| serving-build identifier string in the instance record's |
| `update_report.serving`. It is a digest of the build's **name**, not of |
diff --git a/internal/operator/verification.go b/internal/operator/verification.go| index b7e9aea..154c4ac 100644 |
| --- a/internal/operator/verification.go |
| +++ b/internal/operator/verification.go |
| @@ -6,6 +6,7 @@ import ( |
| "database/sql" |
| "errors" |
| "net/url" |
| + "regexp" |
| "amadan.net/oficina/home/internal/home/directorydata" |
| ) |
| @@ -160,17 +161,15 @@ func (d *Directory) verifyConsumer(ctx context.Context, c *sql.Conn, r Request) |
| result.Expires = in.Expires |
| return encode(result) |
| } |
| -func version(s string) bool { |
| - if len(s) != 40 { |
| - return false |
| - } |
| - for _, c := range s { |
| - if !(c >= '0' && c <= '9' || c >= 'a' && c <= 'f') { |
| - return false |
| - } |
| - } |
| - return true |
| -} |
| + |
| +// observedVersion is the shape app_version must have: the opaque token Alta |
| +// read from the app's /api/version, which every app stamps with `git describe |
| +// --tags --always` (v0.1.0-63-gd867db1, or a bare commit). It is what Alta |
| +// observed, not a platform attestation (team-provisioning-amendment.md §2 |
| +// item 6), so Home bounds it to printable ASCII and checks nothing more. |
| +var observedVersion = regexp.MustCompile(`^[A-Za-z0-9][A-Za-z0-9._+-]{0,127}$`) |
| + |
| +func version(s string) bool { return observedVersion.MatchString(s) } |
| func (d *Directory) activate(ctx context.Context, c *sql.Conn, r Request) ([]byte, error) { |
| var in ActivationInput |
| if DecodeInput(r, &in) != nil || !in.matches(r) || r.authorization.Initial { |
diff --git a/internal/operator/verification_test.go b/internal/operator/verification_test.go| index 15227b8..5c3b2c2 100644 |
| --- a/internal/operator/verification_test.go |
| +++ b/internal/operator/verification_test.go |
| @@ -120,7 +120,7 @@ func TestActivationRejectsChangedStateAndEvidence(t *testing.T) { |
| p.AliasHost = "beta.docs.oficina.works" |
| }, |
| "attempt": func(t *testing.T, f *directoryFixture, p *ActivationEvidence) { p.Attempt = token(95) }, |
| - "version": func(t *testing.T, f *directoryFixture, p *ActivationEvidence) { p.AppVersion = "latest" }, |
| + "version": func(t *testing.T, f *directoryFixture, p *ActivationEvidence) { p.AppVersion = "v0.1.0 dirty" }, |
| "future": func(t *testing.T, f *directoryFixture, p *ActivationEvidence) { p.Completed++ }, |
| "expired": func(t *testing.T, f *directoryFixture, p *ActivationEvidence) { |
| *f.now = f.now.Add(600 * time.Second) |
| @@ -160,6 +160,64 @@ func TestActivationRejectsChangedStateAndEvidence(t *testing.T) { |
| } |
| } |
| +// app_version is what Alta observed on /api/version (amendment §2 item 6): |
| +// any bounded printable-ASCII token, git describe's shape included, and |
| +// nothing that could smuggle whitespace, markup or a path into the evidence. |
| +func TestActivationAcceptsObservedVersionToken(t *testing.T) { |
| + accepted := []string{ |
| + "v0.1.0-63-gd867db1", |
| + "d867db1", |
| + strings.Repeat("a", 40), |
| + "0123456789abcdef0123456789abcdef01234567", |
| + "v1.2.3+build.7_rc-1", |
| + "Z", |
| + "v" + strings.Repeat("1", 127), |
| + } |
| + refused := []string{ |
| + "", |
| + "v" + strings.Repeat("1", 128), |
| + "-v0.1.0", |
| + ".v0.1.0", |
| + "+v0.1.0", |
| + "_v0.1.0", |
| + "v0.1.0 dirty", |
| + "v0.1.0\n", |
| + "v0.1.0/x", |
| + "v0.1.0:x", |
| + "<v0.1.0>", |
| + "v0.1.0\x00", |
| + "v0.1.0-é", |
| + } |
| + for _, s := range accepted { |
| + if !version(s) { |
| + t.Errorf("refused %q", s) |
| + } |
| + } |
| + for _, s := range refused { |
| + if version(s) { |
| + t.Errorf("accepted %q", s) |
| + } |
| + } |
| + for name, observed := range map[string]string{"describe": "v0.1.0-63-gd867db1", "commit": strings.Repeat("a", 40), "refused": "v0.1.0\n"} { |
| + t.Run(name, func(t *testing.T) { |
| + f, in := pendingFixture(t) |
| + _, _, window := openWindow(t, f, in) |
| + p := activation(in, window.Attempt) |
| + p.AppVersion = observed |
| + raw := f.input(t, "directory.activate-consumer", func(b InputBase) any { return ActivationInput{b, p} }) |
| + _, err := f.directory.Execute(context.Background(), raw) |
| + want, wantErr := "live", error(nil) |
| + if name == "refused" { |
| + want, wantErr = "pending", ErrRefused |
| + } |
| + var state string |
| + if err != wantErr || f.db.QueryRow("SELECT state FROM team_instances").Scan(&state) != nil || state != want { |
| + t.Fatalf("%q: err %v state %q", observed, err, state) |
| + } |
| + }) |
| + } |
| +} |
| + |
| func TestOperatorWindowControlsActualRosterReader(t *testing.T) { |
| f, in := pendingFixture(t) |
| source, err := directorydata.NewRosterSource(f.db, f.engine.sealer, f.directory.policy, f.directory.owner.directory) |