Skip to content

Validate secret slots through the system SDK - #1010

Open
tlm wants to merge 6 commits into
secrets-implementationfrom
system-sdk-secret-provider
Open

Validate secret slots through the system SDK#1010
tlm wants to merge 6 commits into
secrets-implementationfrom
system-sdk-secret-provider

Conversation

@tlm

@tlm tlm commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Description

Add validation and normalization for secret slots to the built-in secret interface.

Secret slots:

  • May only be provided by the system SDK.
  • Accept only attributes and collection.
  • Require at least one string-valued search attribute.
  • Require an explicitly supplied collection to be a non-empty string.
  • Default an omitted collection to "default".

The validation was initially implemented as provider-specific preparation under internal/sdk/system. It now lives directly in the secret builtin to match the established pattern where interfaces own validation and normalization of their plug and slot attributes.

The SlotSanitizer contract is also clarified to explicitly permit attribute normalization and defaults while prohibiting changes to slot identity.

Design decisions

The secret builtin owns the complete secret slot contract. This keeps its base declaration, provider restriction, attribute validation, and normalization together and makes its implementation consistent with the other built-in interfaces.

Secret slots remain restricted to the system SDK because it is currently the only supported secret provider.

Testing

  • go test ./internal/interfaces/builtin ./internal/sdk/system
  • Manually exercised valid and invalid secret slot definitions through workshop launch and refresh.

Self-review quick check

  • Make decisions that cost a lot to reverse explicit in the PR description.
  • Avoid nested conditions.
  • Delete dead code and redundant comments.
  • Normalise symmetries by sticking to doing identical things identically.
  • Check that coupled code elements, files, and directories are adjacent.
  • Put variable declaration and initialisation together.
  • Divide large expressions into digestible and self-explanatory ones.
  • Put a blank line between two logically different chunks of code.
  • Follow the style guide for new error messages.

Docs

  • I confirm the PR has no implications for documentation.

@tlm
tlm requested a review from dmitry-lyfar August 31, 2026 03:33
@tlm tlm self-assigned this Aug 31, 2026
@tlm
tlm force-pushed the system-sdk-secret-provider branch from c227c45 to a1f0c0a Compare August 31, 2026 03:53
tlm added 6 commits August 31, 2026 23:45
Add a SlotInfo.CompareByName helper for deterministic slot ordering by name.

This provides a reusable comparator for slices.SortFunc call sites.
The initial secret provider is implemented by the built-in system SDK, so validation of its provider-specific slot metadata belongs with the system SDK rather than the generic secret interface.

Add a system SDK slot preparation entry point that verifies slot ownership and dispatches to interface-specific preparation logic. Leave interfaces without system-specific preparation unchanged so existing system slots continue to behave as before.

Add secret slot preparation that validates the supported attributes and collection keys, requires at least one string-valued lookup attribute, and defaults an omitted collection to "default".

Cover dispatch, validation, and normalization behavior with focused tests.
Secret slot metadata is currently provided only by the built-in system SDK. Keep the secret interface responsible for selecting the supported provider, but avoid embedding system-specific validation rules in the generic interface implementation.

Reject secret slots owned by non-system SDKs, then delegate supported slots to the system SDK preparation entry point. This keeps interface policy and provider routing in the builtin while leaving provider-specific validation and normalization with the system SDK implementation.

Add integration tests covering provider rejection and delegation, including default collection normalization.
Secret slot validation was initially placed in the system SDK package to reflect that the system SDK provides the host keyring integration. This introduced a separate slot preparation dispatcher solely to route secret slots from the builtin interface into provider-specific validation.

Builtin interfaces already own the validation and normalization of their plug and slot attributes. Move the secret schema checks into the secret interface to follow that established structure and keep the complete interface contract in one place.

Continue restricting secret slots to the system SDK, validating lookup attributes and collection values, and defaulting an omitted collection to "default". Move the corresponding tests into the builtin interface package and remove the now-unused system SDK slot preparation layer.
@tlm
tlm force-pushed the system-sdk-secret-provider branch from a1f0c0a to d057791 Compare September 1, 2026 00:36
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.

2 participants