@modelprofile.com/flexharness 5.4.0 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.smartconfig.json DELETED
@@ -1,34 +0,0 @@
1
- {
2
- "@git.zone/cli": {
3
- "schemaVersion": 2,
4
- "projectType": "npm",
5
- "module": {
6
- "githost": "code.foss.global",
7
- "gitscope": "modelprofile.com",
8
- "gitrepo": "flexharness",
9
- "description": "Provider-neutral model-session runtime with durable history, permissions, typed events, and pluggable local or remote tool execution.",
10
- "npmPackagename": "@modelprofile.com/flexharness",
11
- "license": "MIT",
12
- "projectDomain": "modelprofile.com"
13
- },
14
- "release": {
15
- "targets": {
16
- "git": {
17
- "enabled": true,
18
- "remote": "origin",
19
- "pushBranch": true,
20
- "pushTags": true
21
- },
22
- "npm": {
23
- "enabled": true,
24
- "registries": [
25
- "https://verdaccio.lossless.digital",
26
- "https://registry.npmjs.org"
27
- ],
28
- "accessLevel": "public",
29
- "alreadyPublished": "success"
30
- }
31
- }
32
- }
33
- }
34
- }
package/changelog.md DELETED
@@ -1,273 +0,0 @@
1
- # Changelog
2
-
3
- ## 2026-09-02 - 5.4.0
4
-
5
- ### Features
6
-
7
- - add configurable reversion maintenance timeout (reversion)
8
- - Add a top-level reversionMaintenanceTimeoutMs harness option with bounded positive safe-integer validation up to 30 minutes.
9
- - Use the new timeout for turn-reversion inspection, recovery, finalization, and release maintenance signals before falling back to the legacy generation lease cleanup timeout and 30 second default.
10
- - Update documentation and tests for the new timeout behavior and refreshed dependency expectations.
11
-
12
- ## 2026-09-01 - 5.3.3
13
-
14
- ### Fixes
15
-
16
- - use provider-compatible object schemas for project tools (project-management)
17
- - Flatten task, goal, and scratchpad schemas to object roots without union combinators while preserving action-specific validation.
18
- - Reject invalid project tool action shapes before state mutation.
19
- - Preserve valid empty scratchpad set and append operations.
20
-
21
- ## 2026-08-31 - 5.3.2
22
-
23
- ### Fixes
24
-
25
- - allow delegate taskId to remain optional (subagents)
26
- - Set the delegate tool definition to non-strict so new child creation can omit taskId.
27
- - Add coverage for delegate schema required fields and invalid taskId inputs without acquiring delegated run admission.
28
-
29
- ## 2026-08-30 - 5.3.1
30
-
31
- ### Fixes
32
-
33
- - complete delegated child provenance for host authorization (subagents)
34
- - Expose immutable creation origin separately from the current parent delegate invocation and include the reserved child ID in subagent.start permission metadata.
35
- - Carry atomic parent generation, origin, agent, and actual-depth provenance through the optional third `load` and fifth `tombstoneSession` project-management context arguments.
36
- - Persist that provenance in new child cleanup tombstones; older strict schema-1 readers reject the new key, so rollback or mixed-version readers are unsupported after such a snapshot is written.
37
-
38
- ## 2026-08-30 - 5.3.0
39
-
40
- ### Features
41
-
42
- - add delegated child-run admission leases (subagents)
43
- - Add a frozen exact child/current-parent admission context and an optional delegatedRunAdmissionProvider for internally delegated runs.
44
- - Acquire before generation-side reversion, compaction, model, tool, and resource callbacks, while retaining generation-scoped ownership through terminal reversion finalization.
45
- - Close before canonical acceptance or failed/cancelled finalization, preserve abort progress across late acquisition, and retry failed idempotent closes during exact deletion, retirement, or disposal.
46
- - Explain new-child versus later-run resume semantics in the model-visible delegate schema and return safe corrective feedback for unknown task IDs.
47
-
48
- ## 2026-08-26 - 5.2.0
49
-
50
- ### Features
51
-
52
- - add generation-fenced session cohort deletion (session-generation)
53
- - Add deleteSessionGenerationCohort with strict root and authorized cohort validation.
54
- - Allow createSession callers to provide a validated sessionGenerationId while preserving harness-assigned sequences.
55
- - Propagate session generation metadata through model resolver contexts, permission requests, and emitted events.
56
-
57
- ## 2026-08-26 - 5.1.0
58
-
59
- ### Features
60
-
61
- - expose session generation in host-operation callback contexts (harness)
62
- - Add sessionGenerationId and sessionGenerationSequence to tool-provider, resource-resolver, slash-command handler, and turn-reversion contexts.
63
- - Propagate session generation through reversion recovery and deleted-session tombstone cleanup.
64
- - Document generation-aware callback contexts and add coverage for providers, slash commands, and reversion cleanup.
65
-
66
- ## 2026-08-21 - 5.0.0
67
-
68
- ### Breaking Changes
69
-
70
- - stream exact text and reasoning part deltas (events)
71
- - Replace cumulative part.delta payloads with exact untruncated deltas and incremental UTF-8 byte coordinates.
72
- - Separate snapshot and delta event interfaces under TFlexPartEvent and remove IFlexPartChangedEvent.
73
- - Emit empty part.started snapshots before the first text or reasoning delta.
74
-
75
- ## 2026-08-21 - 4.1.2
76
-
77
- ### Fixes
78
-
79
- - emit immediate snapshots for streamed tool outputs (tool-streaming)
80
- - Bump @push.rocks/smartagent to ^5.0.1.
81
- - Verify each distinct async-iterable tool output emits a bounded running part.updated snapshot, including the final yielded value.
82
- - Update documentation for transient streamed tool output behavior.
83
-
84
- ## 2026-08-16 - 4.1.1
85
-
86
- ### Fixes
87
-
88
- - extract harness boundary utilities (harness)
89
- - Move option normalization, validation, transfer bounds, tool output normalization, and store codecs into dedicated internal modules.
90
- - Centralize reserved slash-command name policy and reusable store codec helpers.
91
- - Update package manager metadata to pnpm 11.22.0.
92
-
93
- ## 2026-08-15 - 4.1.0
94
-
95
- ### Features
96
-
97
- - stream transient tool output through cumulative part updates (events)
98
- - Upgrade to SmartAgent 5 and project preliminary tool outputs as bounded immutable `part.updated` snapshots without per-update projection writes.
99
- - Preserve JSON normalization for direct, promise-resolved, and callable async iterables while keeping terminal output authoritative and removing previews on failure or cancellation.
100
- - Document the transient output boundary and cover update ordering, bounds, callback overflow, and final-output replacement.
101
-
102
- ### Fixes
103
-
104
- - remove duplicate transient output release note (changelog)
105
- - Remove the repeated transient tool output changelog entry.
106
-
107
- ## 2026-08-14 - 4.0.2
108
-
109
- ### Fixes
110
-
111
- - pass session generation to project management store loads (project-management)
112
- - Expose IFlexSessionGeneration and add it as an optional third argument to IFlexProjectManagementStore.load.
113
- - Supply a frozen current generation when FlexHarness loads project management records for state reloads and tombstone cleanup.
114
- - Document and test compatibility with existing two-argument callers and stores.
115
-
116
- ## 2026-08-14 - 4.0.1
117
-
118
- ### Fixes
119
-
120
- - preserve large controller scratchpads in project-management state (project-management)
121
- - Increase the project scratchpad limit to 128 KiB and the serialized snapshot limit to 1 MiB so worst-case JSON escaping remains valid.
122
- - Add coverage for maximum UTF-8 and escaped scratchpad payloads.
123
-
124
- ## 2026-08-14 - 4.0.0
125
-
126
- ### Breaking Changes
127
-
128
- - rename the foreground subagent tool and add opt-in project-management tools (harness)
129
- - Rename the foreground subagent wire tool from `task` to `delegate` while retaining durable `taskId` input/output and child-session persistence semantics.
130
- - Add configurable `task`, `goal`, `scratchpad`, and `rename_session` built-ins backed by strict session-local CAS state, public controller APIs, attribution context, and durable deletion fencing.
131
- - Require `IFlexHarnessStores.projectManagement` independently of tool enablement, with generation-aware CAS tombstones and explicit whole-namespace purge.
132
- - Add random durable session generation identity, deterministic legacy backfill, and monotonic generation sequencing so explicit session IDs can be safely reused without stale writes.
133
- - Reserve built-in names only while enabled and reject collisions from application and resource providers before model execution.
134
- - Bound existing `createSession()` and `updateSession()` title inputs to 2048 UTF-8 bytes.
135
-
136
- ## 2026-08-14 - 3.8.0
137
-
138
- ### Features
139
-
140
- - add workspace-required turn reversion (harness)
141
- - Add a versioned provider contract for revertible, no-change, and nonrevertible workspace outcomes with bounded affected-workspace metadata.
142
- - Add workspace-required history grouping, nonrevertible barriers, and public reversion information while preserving the existing transcript-optional policy.
143
- - Upgrade projection persistence to schema version 3 with version 1 and 2 loading, durable cleanup ownership, and crash-safe apply and deletion recovery.
144
-
145
- ## 2026-08-13 - 3.7.0
146
-
147
- ### Features
148
-
149
- - add native slash commands and turn reversion (harness)
150
- - Add built-in, template, and typed-handler slash commands with authoritative parsing, availability, execution, and literal unknown-command fallback.
151
- - Add durable grouped undo and redo with optional workspace capture, crash recovery, branch commitment, release ownership, and archival horizons.
152
- - Upgrade projection persistence to schema version 2 while preserving version 1 loading, and document the public command and reversion contracts.
153
-
154
- ## 2026-08-13 - 3.6.0
155
-
156
- ### Features
157
-
158
- - compose run-scoped resource tool providers (harness)
159
- - Resolve fresh resource providers per run while preserving the existing application tool provider.
160
- - Expose deterministic bounded tool namespaces and bind permissions to non-spoofable resource revision identity.
161
- - Reject duplicate resources, namespaces, and exposed tools before execution, with complete retryable cleanup across failure, cancellation, retirement, and disposal.
162
-
163
- ## 2026-08-13 - 3.5.0
164
-
165
- ### Features
166
-
167
- - add first-class foreground subagent sessions (harness)
168
- - Expose bounded configured subagents through a reserved permission-gated `task` tool with durable child sessions and later-run resume by `taskId`.
169
- - Project child session and model metadata through cumulative `part.updated` events while preserving the terminal tool result.
170
- - Validate persisted parent, origin, agent, depth, and tombstone relationships without changing the existing snapshot schema version.
171
- - Cancel and delete complete session subtrees child-first with retryable cleanup ownership, exact alias contexts, and deadlock-safe namespace fencing.
172
-
173
- ## 2026-08-13 - 3.4.0
174
-
175
- ### Features
176
-
177
- - provide exact invocation context to session compactors (harness)
178
- - Add resolved scope, storage namespace, and session identity to the existing compactor options.
179
- - Keep storage-key aliases isolated across manual, retention, context-overflow, scheduled-cancellation, lifecycle, restoration, and autonomous job-event compaction.
180
- - Emit one terminal part event for each callback-backed streamed text part before run completion.
181
- - Document the projected inputs and no-event compaction case, with shared-storage regression coverage.
182
-
183
- ## 2026-08-11 - 3.3.0
184
-
185
- ### Features
186
-
187
- - allow title updates throughout the session lifecycle (sessions)
188
- - Permit title-only updates while prompts are queued or running, while permission is pending, and after archival.
189
- - Keep archive-bearing requests blocked and atomic while a session has outstanding work.
190
- - Document the mutation boundary and cover active, queued, permission-waiting, archived, and post-run states.
191
-
192
- ## 2026-08-11 - 3.2.0
193
-
194
- ### Features
195
-
196
- - add bounded prompt queue APIs (harness)
197
- - Introduce enqueuePrompt(), queue entry inspection, cancellation, and prompt queue events for FIFO session admission.
198
- - Extend scheduled prompts to share queue ownership with stable schedule keys and cancellable queued work.
199
- - Enforce pending admission, outstanding prompt, byte, and terminal retention limits while clearing private queue payloads at settlement.
200
- - Document queue lifecycle behavior and add coverage for cancellation, disposal, retirement, limits, and immutable queued inputs.
201
-
202
- ## 2026-08-11 - 3.1.0
203
-
204
- ### Features
205
-
206
- - expose authoritative source coordinates on part events (events)
207
- - Add zero-based message and part indexes to started, delta, and completed part events.
208
- - Keep coordinates stable for every update to a part and across later runs.
209
-
210
- ## 2026-08-09 - 3.0.1
211
-
212
- ### Fixes
213
-
214
- - repair crash-interrupted legacy runs during migration (migration)
215
- - Mark running or waiting legacy sessions idle before writing migrated snapshots
216
- - Cancel interrupted streaming messages and running tool or reasoning parts with deterministic recovery timestamps
217
- - Document crash-interrupted migration repair and cover deterministic reruns with tests
218
-
219
- ## 2026-08-09 - 3.0.0
220
-
221
- ### Breaking Changes
222
-
223
- - migrate runtime to AgentSession-backed split stores (harness)
224
- - Replaces the single legacy store and runner integration with domain-specific stores for scopes, projections, permissions, Agent events, and tool jobs.
225
- - Adds scheduled prompts, runtime event APIs, uncertain tool-execution reconciliation, session compaction/archive support, and background execution controls.
226
- - Introduces durable staged terminal recovery, session tombstones, retryable cleanup ownership, commit-uncertain store errors, and JSON store fsync/disposal handling.
227
- - Adds a 2.x legacy snapshot migration export and updates documentation and tests for the 3.x persistence model.
228
-
229
- ## 2026-08-08 - 2.1.0
230
-
231
- ### Features
232
-
233
- - add storage namespace retirement (harness)
234
- - Add retireScope() to stop runtime ownership for resolved storage namespaces without deleting durable snapshots.
235
- - Fence stale scope resolution and late admissions while draining in-flight persistence, permissions, active runs, and tool cleanup.
236
- - Coalesce retirement and disposal drains by storage namespace and preserve isolated cleanup error reporting.
237
- - Document retirement behavior and add lifecycle/resolver tests for concurrency and cleanup paths.
238
-
239
- ## 2026-08-07 - 2.0.0
240
-
241
- ### Breaking Changes
242
-
243
- - project external run errors and add durable prompt/message APIs (harness)
244
- - Convert untrusted resolver, runner, tool, cleanup, callback, and run-persistence failures to FlexHarnessExternalError before exposing them through completions, audit data, events, or disposal.
245
- - Add externalErrorProjector support for application-approved external error projection.
246
- - Add startPrompt() admission semantics plus cursor-based message paging and exact message lookup APIs.
247
- - Add optional resolved model variant metadata and validate it in persisted/public message data.
248
- - Harden permission rollback so failed persistence cannot leave remembered grants reusable.
249
-
250
- ## 2026-08-05 - 1.0.1
251
-
252
- ### Fixes
253
-
254
- - publish JSON Schema typings required by public model types (deps)
255
- - Move @types/json-schema from devDependencies to dependencies so downstream consumers can resolve exported declaration types.
256
-
257
- ## 2026-08-05 - 1.0.0
258
-
259
- ### Breaking Changes
260
-
261
- - Establish the initial 1.0 public API for provider-neutral model sessions.
262
- - Persist successful-only private model history while keeping failed and cancelled prompts audit-visible.
263
- - Redact attachment payloads from public messages and events, exposing metadata only.
264
- - Add revisioned transactional stores, session-scoped permissions, typed immutable events, and explicit lifecycle cleanup.
265
- - Add minimal session title, archive, and deletion mutations with active-run safety.
266
- - Coordinate resolver failure without hanging on an unresponsive sibling and close detached late tool handles.
267
- - Coalesce model callbacks in a bounded run-local buffer instead of persisting every delta.
268
- - Distinguish owner cancellation from internal failure and require successful tool cleanup before appending history.
269
- - Terminalize in-memory audit state and emit terminal events once when final persistence fails.
270
- - Enforce JSON output byte limits incrementally while traversing large values.
271
- - Linearize cancellation at terminal persistence and keep disposal waiting for committing runs.
272
- - Serialize permission checks behind persistence so uncommitted remembered grants are never observable.
273
- - Track detached tool-provider cleanup through disposal and report late close failures.
package/readme.hints.md DELETED
@@ -1,71 +0,0 @@
1
- # readme.hints.md
2
-
3
- Implementation findings for flexharness.
4
-
5
- ## Internal module boundaries
6
-
7
- - `classes.flexharness.ts` owns stateful coordination: admission, queues, canonical finalization, permissions, reversion, persistence reconciliation, resource cleanup, retirement, and disposal. Stateless boundary policy must not be added back to this class.
8
- - Constructor policy belongs in `utils.harnessoptions.ts`; reusable public-input checks belong in `utils.validation.ts`; public projection and transfer bounds belong in `utils.transfer.ts`; tool-result normalization belongs in `utils.tooloutput.ts`.
9
- - Store adapters remain in `classes.stores.ts`, while strict Agent-event and Tool-job codecs belong in `utils.storecodecs.ts`. Store codecs do not own CAS, queue, filesystem, or provider lifecycle behavior.
10
- - Internal utility modules are implementation details and are not re-exported from `index.ts`. Shared policy such as reserved slash-command names and subagent name bounds has one owner and is imported by every caller.
11
-
12
- ## SmartAgent boundary
13
-
14
- - SmartAgent is the canonical private conversation and execution runtime. FlexHarness creates one transactional `AgentSession` per public session and derives its public model, prompt, provider-option, tool-set, and result aliases from SmartAgent exports.
15
- - Non-empty SmartAgent text and reasoning callback deltas cross the public event boundary immediately and exactly once. Delta events never carry a cumulative part and are not subject to snapshot text truncation.
16
- - Public prompts remain JSON-safe. URL strings are converted to `URL` instances only at the private SmartAgent invocation boundary.
17
- - Prompt attachment payloads exist only in canonical private Agent events. Public messages, prompt results, projection snapshots, and events expose only `attachmentType`, source kind, optional media/name, and decoded size when determinable.
18
- - Resolver calls start in promise continuations so synchronous throws are observed. The first failure aborts the shared internal signal without awaiting an ignoring sibling; detached tool-provider settlement is observed and late handles are closed.
19
- - Resource tool composition resolves descriptors per run before provider acquisition, validates duplicate resources and derived namespaces as one set, preserves legacy tool names, and derives bounded resource names from canonical resource/revision and original-tool hashes. Permission identity uses the complete resource digest while provider metadata remains nested below harness-owned attachment metadata.
20
- - Enabled harness-built-in names are checked on every application and resource handle before model execution. The reserved set is run-specific, so a disabled project tool or depth-disabled delegate does not reserve its wire name.
21
-
22
- ## Persistence boundary
23
-
24
- - Snapshot schema version 1 uses optimistic revisions. Harness mutations are serialized per resolved storage key, while the JSON store adds a process-wide per-file queue shared by all instances.
25
- - Every queued mutation snapshots its revision and domain state first. A thrown save is reconciled against the store before memory is restored: a proven prior snapshot rolls back, a proven new snapshot remains current, and an unknown or explicitly uncertain commit fences the namespace. Code that crosses the save `await` must re-fetch session records because a proven rollback intentionally restores them.
26
- - `JsonFileFlexHarnessStores` is intentionally not cross-process safe. It provides atomic rename and in-process CAS, not an operating-system lock.
27
- - Loaded state is repaired from canonical generation outcomes. Accepted hidden terminal stages are promoted, while interrupted or incomplete public messages and tool parts become cancelled so a restarted process never presents them as still running.
28
- - Session updates reject while runtime work is active. Deletion tombstones the session, cancels active work, and retains failed runtime cleanup for a later deletion, retirement, or disposal retry before removing destructive core domains and confirming the retained PM generation fence.
29
- - Tool close settles before canonical acceptance. A completed hidden terminal projection is staged first, the Agent generation is finalized second, and only then is the public projection promoted. Earlier execution failures finalize as interrupted and publish from that durable outcome.
30
- - Disposal waits admitted session initialization, finalizers, every loaded-state save tail, tombstone cleanup, provider release, and detached tool cleanup. Listeners always clear; state caches clear only after cleanup succeeds and otherwise remain owned for retry.
31
- - Canonical finalization is the cancellation linearization point. Abort returns false once a run starts committing, while the active-run entry continues to block new prompts until finalization and public promotion settle.
32
- - Permission callbacks wait for the current save tail and then revalidate their run before reading remembered grants, so neither uncommitted grants nor captured callbacks can authorize later work.
33
- - Detached tool-provider settlement remains tracked after prompt finalization. Failed late handle closure stays owned by its storage state and is retried by a later retirement or disposal call.
34
- - A composed tool handle closes resource and application handles in reverse acquisition order. It attempts every close, aggregates failures, marks only successful handles complete, and retains the composite closure so later lifecycle drains retry exactly the failed handles.
35
- - Scope retirement fences older resolver calls and late state admissions, drains the complete resolved storage namespace, and evicts only the exact cached state promise. It never deletes the durable snapshot. Applications must close admission across every resolver alias before retirement because aliases are unknowable before resolution.
36
- - Context compaction runs under immutable async invocation context rather than storage-state scope hints. This keeps `scopeId`, `scope`, `storageKey`, and `sessionId` exact for manual, retention, and context-overflow compaction even when aliases share one cached namespace. Autonomous job callbacks use their immutable session-owner context because no later public invocation owns them.
37
- - Detached tool-provider cleanup and retained session cleanup are owned by the exact loaded storage state. Failed drains retain that ownership and the cached state for retry. Scope retirement cannot await or consume another namespace's cleanup, while full disposal settles all storage drains and orphaned initialization cleanup before aggregating failures.
38
- - JSON provider release hooks evict non-destructive session wrapper caches after AgentSession and execution-context ownership ends. Failed partial-initialization releases remain storage-scoped orphan ownership and are retried by retirement or disposal.
39
- - Turn-reversion capture release is idempotent and tombstone-owned. Session deletion aborts same-session commands, waits runtime settlement, releases every durable workspace capture, and only then removes projection data; a failed or unacknowledged release leaves the tombstone and projection available for retry.
40
- - Turn-reversion inspection, recovery, finalization, and release use a dedicated aggregate maintenance timeout. The top-level reversion option takes precedence over the legacy agent-session cleanup timeout fallback so hosts can order provider-call, aggregate-maintenance, and enclosing lifecycle deadlines independently.
41
- - Projection schemas 1 and 2 remain read-only compatibility inputs. Every projection write uses schema 3 with explicit protocol, provenance, and V2 disposition; schema-2 workspace references migrate as protocol-1 ownership without being discarded.
42
- - A loaded schema-1 or schema-2 projection retains its exact durable baseline until the first schema-3 save is confirmed, so a non-committing upgrade failure rolls back without fencing while a post-commit throw reconciles the new schema.
43
- - Workspace-required traversal keeps the cursor in completed-root group coordinates. Candidate operations may jump across trailing no-change groups, while pending, nonrevertible, mixed, and legacy transcript groups remain barriers without changing transcript-optional grouping.
44
- - `JsonFileFlexHarnessStores.dispose()` is the explicit final drain for file handles whose close failed on the last store operation; failed disposal retains the handle for another call.
45
- - Project-management state is a required exact `(storageKey, sessionId)` member of `IFlexHarnessStores`; `builtInTools.projectManagement` only controls tool exposure. Harness-local operations serialize without retrying external mutation conflicts, no-op mutations do not save, and tool writes retain agent/run/tool-call attribution. Session cleanup always runs, waits the local queue, and boundedly reloads before writing a generation-owned tombstone. Random generation identity plus a monotonic core-scope generation sequence permits a newer session to replace only an older PM tombstone while fencing stale saves and tombstones. Normal cleanup never removes the fence; `purgeNamespace()` is reserved for serialized application-owned whole-namespace destruction after non-destructive retirement and core-scope purge.
46
-
47
- ## Tool output boundary
48
-
49
- - Every tool `execute` result and every async-iterable yield is converted to bounded JSON before SmartAgent observes it. Thrown errors and iterator failures are not converted or swallowed.
50
- - Every distinct SmartAgent streamed tool output mutates only the run-local running tool part and immediately emits a cumulative `part.updated` snapshot, including the final yielded value. Terminal success replaces it with the authoritative final output; failure, cancellation, and callback overflow remove transient output before persistence.
51
- - JSON byte limits are propagated through traversal. Large strings never enter normalized output, and array/object traversal stops once the remaining allowance is reserved for deterministic truncation metadata.
52
- - Model callbacks use bounded synchronous run-local parts. Source text/reasoning deltas accumulate there without per-delta persistence, while public `part.delta` events retain each exact source delta. Per-part UTF-8 counters are updated incrementally, including correction when a source boundary splits a surrogate pair; cumulative text is never rescanned per token. Callback event, byte, or part overflow aborts internally and is classified as failure, not owner cancellation.
53
-
54
- ## Prompt queue boundary
55
-
56
- - Each loaded session owns one bounded runtime FIFO. Queue records retain private normalized prompt input and options only until terminal settlement; public queue entries and events expose IDs, status, timestamps, schedule keys, and projected errors only.
57
- - Never-started queue entries are intentionally not persisted. Scope and projection stores are public/redacted, Agent events are canonical model transactions, and the SmartAgent job store is reserved for background execution state. Reusing any of them for queued prompt payloads would violate its trust or lifecycle contract.
58
- - `enqueuePrompt()` is the runtime acceptance point. Existing `startPrompt()` and `schedulePrompt()` wait for the same entry's durable promotion, preserving their canonical reservation guarantee.
59
- - Promotion installs active ownership before its first await and checks cancellation, lifecycle, and exact stored-session identity after every durable boundary. Cancellation before start events interrupts and rolls back the canonical claim; cancellation afterward uses the active AgentSession path.
60
- - Deletion tombstones before queue cancellation. Scope retirement, namespace fencing, and disposal fence promotion before cancelling queued and active entries. Queue listeners remain available through deletion and retirement and clear only after disposal has emitted terminal events.
61
-
62
- ## Subagent ownership
63
-
64
- - Subagents are first-class FlexHarness sessions. Public callers cannot assign relationship fields; private creation persists a complete parent/origin/agent/depth relation under the storage-key scope mutation before runtime initialization.
65
- - The built-in `delegate` tool consumes its per-run call slot when schema-valid execution starts, before semantic validation. Tool-schema rejection never enters execution and consumes no slot. Successful semantic validation reserves the child ID before requesting `subagent.start` permission; bounded permission metadata includes that reserved ID, which remains consumed after rejection or failure even though permission rejection creates no child session. The ID is correlation rather than existence authority. New child IDs hash the version marker, raw storage key, parent session, parent run, and parent tool call; the storage key itself is never exposed.
66
- - SmartAgent's parent tool intent remains crash authority. A deterministic child with messages is treated as an uncertain prior execution, while explicit `taskId` resume is limited to a later run of the same parent and same configured agent.
67
- - The SmartAgent tool-start callback establishes the correlated running parent part before execution. Harness-owned child ID/model metadata mutates that part synchronously and emits cumulative `part.updated` snapshots within the existing callback budgets.
68
- - Parent abort listeners recheck immediately after registration and abort only the captured active child run ID. Listener removal is in `finally`, including child failures and cancellation.
69
- - Scope snapshots retain schema version 1. Strict validation accepts legacy roots without relationship/depth fields, while new roots use depth 0 and children require complete relations, a live parent, exact parent-plus-one depth, no duplicate origin, no cycle, and no tombstoned ancestor.
70
- - Deletion persists one root-keyed tombstone group for the requested live subtree and joins separately retained descendant groups without rewriting their root invariants. Tombstones retain bounded immutable immediate-parent ancestry plus one atomic child provenance block with exact parent generation, creation origin, agent, and actual session depth. Project-management cleanup receives a cloned, doubly frozen context reused by identity across one cleanup's CAS retries and reconstructed from persisted provenance after restart. Active runs are cancelled only after the save, explicit retries first retry orphaned late-initialization cleanup, initialization barriers settle before domain cleanup, and runtime plus domains proceed child-first. Any failure retains ownership; the requested root is removed only after every joined descendant group is clean.
71
- - Namespace fencing cancels all other runs immediately. It awaits only relationship-independent runs in the failing turn; ancestor and descendant runs settle through the owned storage drain after the current run rejects, preventing a child-to-parent wait cycle while preserving fail-closed disposal and retirement retry ownership.