Document extension concurrency and ownership
This commit is contained in:
@@ -146,6 +146,9 @@ Other callers may attach their own native observer. See the
|
||||
[native observation contract][observations] and
|
||||
[ownership decision](../adr/0025-use-consumer-owned-execution-observation.md);
|
||||
do not add overlapping totals or a durable profile inventory.
|
||||
Shared callbacks must tolerate overlapping operations and own their mutable
|
||||
state. Injected clients and observers follow the pinned [PromptKit consumer
|
||||
contract][consumer] and its linked GoDoc, not stronger local guarantees.
|
||||
|
||||
[Native capture](../../internal/framework/capture/native.go) composes
|
||||
observers/preparation callbacks rather than replacing them. Retain prepared
|
||||
|
||||
@@ -96,7 +96,25 @@ Preparation transfers returned values and callbacks to that operation; a shared
|
||||
module must not store mutable operation state. Own mutable slices/maps that a
|
||||
callback might modify and respect the existing detached input boundaries.
|
||||
Optional evidence projections are lazy and only invoked when capture is enabled.
|
||||
This does not promise thread safety for caller-supplied writers or observers.
|
||||
|
||||
The selected extractor instance and its extraction validators are reused across
|
||||
chunk jobs, so preparation and validation calls can overlap. Registered codecs
|
||||
are shared and their methods can overlap too. Keep mutable operation state in
|
||||
the invocation or synchronize retained mutable fields; detached validator views
|
||||
do not protect receiver state. Parsed source and its shared index are read-only.
|
||||
Chunk preparation precedes extraction. A lane's merge and normalization run in
|
||||
order after its extracts, but can overlap other lanes' work; this is not a claim
|
||||
that every stage method is universally concurrent.
|
||||
|
||||
Callbacks and evidence projections belong to their operation. Borrowed source,
|
||||
references, writers, and other collaborators must not be used after their valid
|
||||
lifetime. If an extension starts background work, it owns stopping and joining
|
||||
it before releasing those collaborators: the runner joins dispatched operations,
|
||||
not arbitrary extension goroutines. Shared callbacks and explicitly supplied
|
||||
evidence writers must support concurrent calls when used by concurrent jobs.
|
||||
The [recorder](../../internal/framework/debug/recorder.go) is synchronized;
|
||||
per-operation wrappers do not serialize a shared external writer. Native client
|
||||
and observer obligations are owned by the pinned [PromptKit contract](llm.md#native-evidence-and-sensitive-data).
|
||||
|
||||
## Validators And Deterministic Work
|
||||
|
||||
|
||||
@@ -137,6 +137,8 @@ chunk positions select the scoped terminal error among reported failures rather
|
||||
than response timing. Parent cancellation takes precedence. On failure/cancellation
|
||||
the coordinator stops dispatch, drains started results, closes jobs, and joins
|
||||
workers before returning. Output encoding does not run after terminal failure.
|
||||
This join covers dispatched operations, not background goroutines started by an
|
||||
extension; those remain the extension's responsibility.
|
||||
|
||||
Nested validation and correction use the operation's worker, not another worker
|
||||
permit. Native backend admission is independent and released before candidate
|
||||
|
||||
@@ -156,6 +156,11 @@ detached details cheaply; ordinary boundaries write prepared contracts, native
|
||||
results, raw response text, and full readable exchanges. Events are written
|
||||
incrementally. Scope includes operation/step/lane/chunk/validator identity to
|
||||
avoid concurrent evidence collisions.
|
||||
The built-in [recorder](../../internal/framework/debug/recorder.go) serializes
|
||||
its writes. An explicit writer selected by the runner is shared directly and
|
||||
must support overlapping calls from concurrent operations; separate native
|
||||
capture instances do not add a common lock around that writer. The caller owns
|
||||
its lifetime through completion of dispatched work.
|
||||
|
||||
When capture is enabled, the CLI attaches its own native execution group to
|
||||
the inherited invocation context after allocation. Its finish path writes one
|
||||
|
||||
Reference in New Issue
Block a user