credentialFile {{.Scopes}}: capture and persist the token response scope #225

Closed
opened 2026-10-27 13:35:27 +00:00 by sam · 0 comments
Owner

{{.Scopes}} has no source anywhere in archie, so egkf.14 is blocked on this.
The published Claude Code Kit renders scopes: "{{.Scopes}}" (credentialFile.structure),
and the renderer refuses an unsourceable placeholder by design.

Every link in the chain is missing (verified at commit 7d34b57f):

  • capture does not read the field: internal/infrastructure/egress/oauth.go:239-256 parses
    only access_token / refresh_token / token_type / expires_in. RFC 6749 section 5.1 puts the
    granted scopes in a space-delimited scope string, which nothing here looks at.
  • the domain token set has no field: internal/domain/harnesssecret/harnesssecret.go:17-25
    (Org, Service, AccessToken, RefreshToken, TokenType, ExpiresAt, UpdatedAt).
  • the persisted shape has no field: internal/infrastructure/postgres/harness_secrets.go:22-27
    (harnessSecretPayload). It is JSON inside the encrypted envelope, so no SQL migration is
    needed; the envelope is the whole token set.
  • the wire contract has no field: proto/state/v1/state.proto:634-642 (message HarnessSecret).
    This is mandatory, not optional: the daemon reads the set through a gRPC client
    (internal/app/archied/bootstrap.go:424, b.stateStore = client), so a field that is only
    added to the local struct is lost in production.
  • the mapping has to carry it: internal/infrastructure/staterpc/values.go HarnessSecret
    to/from proto.

Change shape: parse scope in capture into []string (split on space, drop empties, keep the
previous set when the field is absent -- providers may omit it), add Scopes to
harnesssecret.Secret and harnessSecretPayload, add repeated string scopes to the proto and
regenerate, map it in values.go, then have kitrun.oauthExpiries pass it alongside the expiry
and the renderer substitute an array for {{.Scopes}}.

Acceptance: a Kit whose credentialFile references {{.Scopes}} launches, the rendered file holds
a JSON/TOML array of the granted scopes, and no real access or refresh token appears in it.

Notes

Merged and gated. Capture parses the token response's scope with strings.Fields and keeps the previous set when the field is absent (mirroring the refresh-token rule); harnesssecret.Secret.Scopes; harnessSecretPayload.Scopes (JSON in the encrypted envelope, so no migration); proto HarnessSecret repeated string scopes = 8; staterpc values.go maps both ways with slices.Clone on the wire->domain direction. Proved by a real proxy-path test (present scope replaces, absent scope preserves) and the local+grpc conformance round trip on real Postgres.

Close reason

Closed


Imported from beads archie-core-egkf.15 · GitHub #1422 · type task · priority P1 · created 2026-09-29 · closed 2026-09-29

{{.Scopes}} has no source anywhere in archie, so egkf.14 is blocked on this. The published Claude Code Kit renders scopes: "{{.Scopes}}" (credentialFile.structure), and the renderer refuses an unsourceable placeholder by design. Every link in the chain is missing (verified at commit 7d34b57f): - capture does not read the field: internal/infrastructure/egress/oauth.go:239-256 parses only access_token / refresh_token / token_type / expires_in. RFC 6749 section 5.1 puts the granted scopes in a space-delimited `scope` string, which nothing here looks at. - the domain token set has no field: internal/domain/harnesssecret/harnesssecret.go:17-25 (Org, Service, AccessToken, RefreshToken, TokenType, ExpiresAt, UpdatedAt). - the persisted shape has no field: internal/infrastructure/postgres/harness_secrets.go:22-27 (harnessSecretPayload). It is JSON inside the encrypted envelope, so no SQL migration is needed; the envelope is the whole token set. - the wire contract has no field: proto/state/v1/state.proto:634-642 (message HarnessSecret). This is mandatory, not optional: the daemon reads the set through a gRPC client (internal/app/archied/bootstrap.go:424, b.stateStore = client), so a field that is only added to the local struct is lost in production. - the mapping has to carry it: internal/infrastructure/staterpc/values.go HarnessSecret to/from proto. Change shape: parse `scope` in capture into []string (split on space, drop empties, keep the previous set when the field is absent -- providers may omit it), add Scopes to harnesssecret.Secret and harnessSecretPayload, add `repeated string scopes` to the proto and regenerate, map it in values.go, then have kitrun.oauthExpiries pass it alongside the expiry and the renderer substitute an array for {{.Scopes}}. Acceptance: a Kit whose credentialFile references {{.Scopes}} launches, the rendered file holds a JSON/TOML array of the granted scopes, and no real access or refresh token appears in it. ### Notes Merged and gated. Capture parses the token response's scope with strings.Fields and keeps the previous set when the field is absent (mirroring the refresh-token rule); harnesssecret.Secret.Scopes; harnessSecretPayload.Scopes (JSON in the encrypted envelope, so no migration); proto HarnessSecret repeated string scopes = 8; staterpc values.go maps both ways with slices.Clone on the wire->domain direction. Proved by a real proxy-path test (present scope replaces, absent scope preserves) and the local+grpc conformance round trip on real Postgres. ### Close reason Closed --- _Imported from beads `archie-core-egkf.15` · GitHub #1422 · type task · priority P1 · created 2026-09-29 · closed 2026-09-29_
sam added the hightask labels 2026-10-27 13:35:27 +00:00
sam self-assigned this 2026-10-27 13:35:27 +00:00
sam closed this issue 2026-10-27 13:35:28 +00:00
sam added a new dependency 2026-11-14 14:45:12 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Reference: sam/archie#225