Skip to content

Move executor credentials, installations and file writes into sessions and sessionpg - #341

Merged
SaladDay merged 1 commit into
mainfrom
refactor/sessions-environments-b
Sep 30, 2026
Merged

SaladDay merged 1 commit into
mainfrom
refactor/sessions-environments-b

Conversation

@SaladDay

@SaladDay SaladDay commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

Executor credential issuance, rotation and revocation, native Environment installation and Environment file writes move out of store into sessions and sessionpg. This completes PR 17; #336 moved Environments and devices.

What changes

  • Executor credentials: sessions.Service use cases for:

    • the CLI principal's Issue, Rotate and Revoke;
    • the Project's Issue (with rotate) and Revoke.

    sessionpg applies them. The Core-key Project operations record their admin audit entry in the same transaction. The Project credential state is a reader method, which api reads through EnvironmentsReader.

  • Native installation: Authorize, Validate and Claim are sessions use cases. sessions builds and parses the token, and sessionpg.Store signs and verifies it with the credential key, so the key stays in the adapter. The token format and signature are unchanged, so tokens issued before this change still verify.

  • File writes: reservation and settlement are lease-bound ExecutionOperations (the EnvironmentExecution family). The file-write lookup is internal to sessionpg.

  • Wiring: cmd/environment-key builds a keyless Session service and no longer imports store.

  • Removed from store:

    • environment_installation.go
    • environment_executor_credentials.go
    • executor_credential_target.go
    • environment_executor_management.go
    • environment_file_writes.go
    • ListProjectExecutorCredentials
  • Docs:

    • IMPLEMENTATION.md names the new owners.
    • sessionpg.LoadSessionEnvironment had no external caller, so it is unexported.

Behavior

  • Missing credential key: it now returns 503 credential_storage_unavailable.
    • Before, installation authorize returned 500, and the grant validate and claim routes returned 401.
    • The same 503 applies to the Core installation read and to /v1 Session retrieve and update for a self_hosted Session.
    • The contract doc and route annotations say so. The generated OpenAPI changes only by those response codes.
  • CLI revoke: it runs in a transaction.
  • File writes: the pre-reads run inside the lease transaction, and settling an unknown write returns not found.
  • Unchanged: everything else. That covers lock order, the executor-credential conflict rules, audit rows, file-write receipts and write audit, and error precedence.

Checks

  • go build ./..., go vet ./services/core/..., make openapi (the committed diff is only the response codes above) and scripts/check-names.py.
  • sessions and sessionpg in full.
  • store -run on the touched tests: 46 pass, including the official-client and environment-key binary tests.
  • api -run on the Environment, installation, executor and error-mapping tests.
  • execution -run 'Environment|FileWrite'.
  • cmd/environment-key and cmd/server in full.

The blind review found no blockers or majors. Its three minor findings are fixed in this commit: the undocumented 503, an overclaim about which operations are audited, and a stale comment.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

@SaladDay
SaladDay merged commit aa31cec into main Sep 30, 2026
1 check passed
@SaladDay
SaladDay deleted the refactor/sessions-environments-b branch September 30, 2026 23:05
…s and sessionpg

Executor credential issuance, rotation and revocation, for the CLI
principal and for a Project's self_hosted Environment, are
sessions.Service use cases: sessions checks the principal, target and
archived Project and decides each outcome, and sessionpg applies it in
one transaction. The Core-key Project operations record their
administrator audit entry in that transaction.
ProjectExecutorCredentialState joins sessions.ExecutorCredentialReader,
and api reads it through EnvironmentsReader. Native installation
authorization, validation and claim are sessions use cases, and the
pooled sessionpg.Store signs and verifies installation tokens with the
credential key; without one they are credentialcrypto.ErrUnavailable,
which validation and claim return unchanged. The executor credentials
contract and the OpenAPI documents list the resulting 503
credential_storage_unavailable on the grant routes, the Core-key
installation read and the self_hosted Session retrieve and update.
cmd/environment-key builds a keyless Session service.

File-write reservation and settlement join EnvironmentExecution on
sessionpg.NewExecution(lease): each loads, decides and applies in one
leased Session transaction, and the write-audit source is stored with
the intent and recorded when the write commits. The Worker runs them
through the Session execution operations. sessionpg's
loadSessionEnvironment is no longer a participant of other adapters.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant