Add immutable namespace views

This commit is contained in:
2026-10-17 06:14:09 +00:00
parent 60c58260ec
commit aa54b8d1c4
8 changed files with 347 additions and 2 deletions

View File

@@ -63,6 +63,33 @@ new engine to observe configuration edits. See the [constructor GoDoc](../../eng
for the exact public contract and the [framework format reference](../formats.md)
for definition fields.
### Use Scoped Engine Views
Create a view when an application wants short request IDs to resolve within a
selected collection:
```go
scoped, err := engine.WithNamespaces(promptkit.Namespaces{
Prompt: "support",
Profile: "support",
})
if err != nil { return err }
prepared, err := scoped.Prepare(ctx, promptkit.RunRequest{
PromptID: "answer",
ProfileID: "concise",
})
```
Ordinary execution and preparation qualify slashless caller selections with
their respective namespace. Already-qualified IDs pass through unchanged;
configured defaults and references are not rewritten. Each call replaces the
view's scope defaults, including clearing a scope with an empty field, without
changing the receiver or rebuilding its captured configuration and execution
collaborators. Namespace syntax is checked when creating the view; resource
existence is checked when selected. See [`WithNamespaces`](../../namespaces.go)
for the exact public contract.
## Supply Embedded Application Defaults
Use `FilesystemInputs` for embedded defaults and `DirectoryInputs` for an

View File

@@ -19,7 +19,7 @@ contributor workflow and validation.
| `internal/configuration` | Loads keyed backend, profile, and prompt configuration through ConfigKit; records effective field presence, validates final values including optional diagnostic metadata, captures indexed prompt definitions, referenced message content, compiled templates, input metadata snapshots, sorted identity-only profile and prompt inventories, backend and presence-aware profile snapshots, and an explicit read-only inspection view. | [Typed loader](../../internal/configuration/load.go), [identity listing](../../internal/configuration/listing.go), [internal sources](sources.md#typed-configuration-loading) |
| `internal/capacity` | Owns engine-local bounded execution admission and FIFO model-generation permits for limited backend IDs, including cancellation-safe waiter removal and client wrapping. | [Internal capacity management](capacity.md) |
| `internal/domain` | Defines internal framework values for requests, artifacts, prompt definitions, requirement inspection, profiles, execution targets, rendering, generation, validation, and source-neutral smoke diagnostics, and owns source-neutral invariants for shared execution settings, OpenAI-compatible base endpoints, session identifiers, output contracts, and resource-identity syntax and qualification. Source parsing, required fields, other source-specific normalization, defaulting, and boundary-specific error classification remain with their callers. | [Domain declarations](../../internal/domain/domain.go), [requirement values](../../internal/domain/requirements.go), [endpoint invariant](../../internal/domain/endpoint.go) |
| `internal/engine` | Assembles caller-selected configuration into one snapshot, then constructs shared capacity, rendering, validation, generation, repair, the ordinary runner, and the smoke tester for each engine. Built-in engines provide the diagnostic HTTP collaborator; injected-client engines do not. It delegates identity listing directly to the captured configuration inventory rather than the runner. | [Engine assembly](../../internal/engine/engine.go), [internal sources](sources.md#typed-configuration-loading), [internal runner](runner.md) |
| `internal/engine` | Assembles caller-selected configuration into one snapshot, then constructs shared capacity, rendering, validation, generation, repair, the ordinary runner, and the smoke tester for each engine. Immutable namespace views share those collaborators and qualify ordinary request selections. Built-in engines provide the diagnostic HTTP collaborator; injected-client engines do not. It delegates identity listing directly to the captured configuration inventory rather than the runner. | [Engine assembly](../../internal/engine/engine.go), [internal sources](sources.md#typed-configuration-loading), [internal runner](runner.md) |
| `internal/generation` | Coordinates frozen built-in HTTP attempts and one-shot injected calls through active backend permits, including bounded status retries, cancellable backoff, ordinary attempt observations, and invocation-local evidence for diagnostics. | [Internal generation coordination](generation.md) |
| `internal/defaults` | Defines application-neutral framework constants and constructs the default execution target. It contains no CLI, server, or inbound HTTP limits. | [Framework defaults](../../internal/defaults/defaults.go) |
| `internal/filecatalog` | Provides deterministic YAML discovery and path helpers for operating-system filesystems and `fs.FS` sources. | [File catalog](../../internal/filecatalog/catalog.go) |

View File

@@ -619,6 +619,16 @@ Scope: public `Namespaces`/`WithNamespaces` and shared engine-boundary routing.
Validation: root/prepared/usecase tests and focused race-enabled scope tests.
Use injected generation or a controlled HTTP boundary; never a live endpoint.
Completion: added immutable `WithNamespaces` views that share the assembled
runner and captured configuration. Ordinary `Run`, `Prepare`,
`PrepareExecution`, and the preparation-backed `ValidateRequest` now qualify
slashless caller prompt/profile IDs while preserving qualified IDs, captured
defaults, full result/event identities, and prepared-handle ownership behavior.
Tests cover independent views, replacement and clearing, no fallback, absent
well-formed namespaces, invalid syntax, and concurrent preparation. Validation
passed: `GOWORK=off go test ./...`, focused `GOWORK=off go test -race . -run
'TestWithNamespaces' -count=1`, `GOWORK=off go vet ./...`, and `git diff --check`.
## Stage 13: Apply Scopes To Inspection And Diagnostics
Scope: complete the existing operation inventory without a second resolver.