You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
state: add authoritative native session inventory and deletion
Before this commit: native session discovery was embedded in continuity
selection, and AgentX had no provider-free CLI inventory or identity-bound
deletion contract.
After this commit: AgentX provides workspace-scoped, paginated
`--list-sessions` and revision-bound `--delete-session` modes backed by one
runtime-owned session manager. Resume, continue, fork, and explicit creation
use the same authoritative inventory and deletion state.
Tests: pass `go test ./... -count=1`, `go test -race ./... -count=1`, and
`go vet ./...`. Cross-build `go build ./...` for Darwin, Linux, and Windows on
amd64 and arm64, and pass architecture, conformance, diagram, and skill checks.
More info: management mode rejects conversation-starting options and emits one
versioned JSON result. Deletion revalidates workspace, session, transcript,
lock, and revision identities; holds the existing nonblocking lock through a
same-parent atomic detach and directory sync; then performs bounded,
descriptor-rooted cleanup. Recoverable staging reports `delete_incomplete`
instead of deleted. Deletion covers only the local native session directory
and does not remove backups, project memory, worktrees, descendants,
authentication or configuration, or VS Code presentation caches.
Copy file name to clipboardExpand all lines: .codex/skills/coding-directives/references/runtime-architecture.md
+54-7Lines changed: 54 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,18 @@
1
1
# AgentX architecture
2
2
3
+
## Contents
4
+
5
+
-[Runtime boundary](#runtime-boundary)
6
+
-[Component ownership](#component-ownership)
7
+
-[Application home and Azure `gpt-5.6-sol` mapping](#application-home-and-azure-gpt-56-sol-mapping)
8
+
-[Turn and tool ordering](#turn-and-tool-ordering)
9
+
-[Permissions and deliberate hardening](#permissions-and-deliberate-hardening)
10
+
-[Transcript and recovery](#transcript-and-recovery)
11
+
-[Surfaces and control plane](#surfaces-and-control-plane)
12
+
-[Trust and extension plane](#trust-and-extension-plane)
13
+
-[Feature profile](#feature-profile)
14
+
-[Validation strategy](#validation-strategy)
15
+
3
16
## Runtime boundary
4
17
5
18
This implementation follows the language-neutral contracts reachable from the repository `AGENTS.md` and `.codex/skills/implementation-*`. Package dependencies point inward toward a single semantic runtime:
@@ -8,7 +21,10 @@ This implementation follows the language-neutral contracts reachable from the re
8
21
main.go
9
22
→ build identity, signal ownership, and private application-home bootstrap
10
23
→ early CLI/mode selection and required auth.json existence gate
11
-
→ strict model credential parsing, provider, platform, and session construction
24
+
→ provider-free native session inventory/deletion
25
+
→ normalized absolute workspace and runtime-owned session manager
26
+
→ bounded text or one-object JSON result
27
+
→ otherwise strict model credential parsing, provider, platform, and session construction
12
28
→ immutable extension and capability snapshots
13
29
→ prompt/context projection
14
30
→ shared engine
@@ -48,7 +64,7 @@ The operational target in this tree is the local-agent core. It is not a declara
48
64
|`pkg/model`| Provider-neutral requests/events plus the Azure OpenAI Responses API adapter. |
|`pkg/sandbox`, `pkg/sessionlock`| Explicit OS-isolation availability and exclusive durable-session ownership. |
62
-
|`pkg/platform`, `pkg/observability`| Production platform detection, credential-filtered session-scoped Zap diagnostics, atomic diagnostic fallback, and ordered cleanup plus reusable process/filesystem contracts; OS signal acquisition belongs to `pkg/signals`, and not every portable helper has a production caller. |
|`pkg/platform`, `pkg/observability`| Production platform detection, descriptor-rooted owned-directory inspection/detach/sync/cleanup, credential-filtered session-scoped Zap diagnostics, atomic diagnostic fallback, and ordered cleanup plus reusable process/filesystem contracts; OS signal acquisition belongs to `pkg/signals`, and not every portable helper has a production caller. |
63
79
|`pkg/distributed`, `pkg/features`| Contract-only remote identity/delivery primitives and explicit multi-axis feature availability; no remote transport is registered. |
64
80
|[VS Code extension repository](https://github.com/greenpau/agentx-vscode-extension)| External workspace-host adapter for process placement, NDJSON framing and correlation, Workspace Trust gating, editor-context projection, bounded presentation state, webview rendering, diagnostics, and target-specific VSIX packaging. It owns no session, transcript, permission-policy, or tool-execution truth. |
65
81
@@ -82,6 +98,10 @@ before full CLI parsing. Credential gates and reads open that child
82
98
descriptor-relative to the pinned home and reverify the textual home identity
83
99
afterward, so replacing the pathname cannot redirect credential selection.
84
100
Help, version, and standalone MCP stop if it is absent but do not parse it.
101
+
Native session inventory and deletion preserve the same frozen-home and
102
+
`auth.json`-presence bootstrap, then branch before credential parsing,
Model-backed surfaces strictly accept only the version-1 `azure_openai` schema
86
106
from that file under `AUTH-045`; it is their sole model credential source.
87
107
Supported POSIX platforms enforce effective-user ownership and private mode
@@ -192,12 +212,39 @@ Legacy records without response identity use conservative per-call synthesis.
192
212
193
213
Fork selects the active durable projection, restamps identifiers, and appends the destination batch without copying ephemeral recovery evidence. A durable incomplete-publication marker is created before the copy and removed only after the copied transcript loads successfully; `--continue`, explicit resume, and destination reuse reject or ignore marked sessions. Source and destination are still independent stores rather than one cross-store transaction, but a process failure cannot publish a copied prefix as a resumable completed fork.
194
214
215
+
One runtime-owned session manager derives the v1.0.6 workspace partition from
216
+
the frozen `sessions/` capability and normalized absolute workspace. Its
217
+
bounded, paginated inventory includes only grammar-valid native sessions with
218
+
direct single-link transcript and lock identities; incomplete forks and
219
+
deletion staging are not resumable. Ordering is transcript modification time
220
+
descending and session ID ascending. Opaque revisions bind workspace parent,
221
+
session directory, transcript, and lock identities. Deletion acquires the
222
+
existing nonblocking lock, commits durable intent, repeats identity and
223
+
revision checks at the mutation boundary, atomically renames the live directory
224
+
within the same parent to a reserved invalid-session staging name, syncs the
225
+
parent where supported, and releases the lock only after normal selectors
226
+
cannot reach the old name. Descriptor-rooted cleanup then removes the detached
227
+
owned directory. A cleanup failure remains visible as retryable staging and is
228
+
reported as `delete_incomplete`; `deleted` means only that the selected native
229
+
AgentX directory and contents are absent, not secure media erasure or deletion
230
+
of backups, remote copies, project memory, worktrees, fork descendants,
231
+
configuration, authentication, or presentation caches.
232
+
195
233
Provider-output metadata, semantic assistant messages, tool calls, and results are intentionally separate. Semantic data remains readable and presentation-neutral while opaque encrypted provider state can be replayed without pretending it is model reasoning text.
196
234
197
235
## Surfaces and control plane
198
236
199
237
Interactive, headless text, single-result JSON, and live NDJSON all use the same engine. Every surface classifies syntactically valid slash commands before model submission. Noninteractive registries advertise only descriptor-opted-in commands; recognized-but-unsupported and valid-unknown commands fail locally, while invalid slash grammar remains ordinary prompt text. Structured stdout contains JSON records only; warnings and session-scoped diagnostic logs use stderr. Routine turn start and successful-completion diagnostics are DEBUG, so the default INFO threshold keeps successful turns quiet while WARN and ERROR conditions remain eligible. `-d` or `--debug` adds bounded turn-correlated lifecycle records plus session, model-iteration, stream, retry, capability, usage, timing, and terminal metadata; retry warnings carry session and model identity. For persistent sessions, the accepted user event, provider-usage records, and terminal turn result remain authoritative in the append-only transcript regardless of logger level whenever their append and flush succeed. Diagnostics never admit prompts, model text, tool arguments or results, file contents, headers, bodies, or configured credential values. The decoder handles arbitrary chunks, blank lines, a final unterminated record, malformed-input failure, and unknown-type warnings. U+2028/U+2029 are escaped.
200
238
239
+
The additive `--list-sessions` and `--delete-session` modes are separate
240
+
provider-free CLI adapters, not headless turns or duplex SDK controls. Their
241
+
exact allowlist requires `--cwd`, permits only text or one versioned JSON
242
+
object on stdout, and rejects prompts and all conversation, model, permission,
243
+
tool, extension, MCP, persistence, and stream-JSON options. Pagination and
244
+
revision tokens are opaque. The shared session manager, rather than the CLI
245
+
renderer or VS Code presentation cache, owns filesystem enumeration and
246
+
mutation.
247
+
201
248
The live reader continues while a turn runs so permission/control responses cannot deadlock behind model execution. Control waiters register before emission. User messages enter a bounded stable-priority queue; a `now` record cancels the current turn and then runs as the next serialized workload, while `next` and `later` wait. This is queued-turn preemption, not injection of new context into an in-flight recursive model/tool turn. Duplicate UUIDs are silent unless replay acknowledgement is enabled, in which case a schema-valid replay user record is emitted without execution. Interrupt returns a correlated control response and cancels the active turn; accepted tool IDs still settle before idle. Public records use the closed SDK discriminator union rather than wrapping internal protocol events. Initialize-time hook/MCP/prompt/agent/schema injection, historical assistant replay, and live environment/model/permission-mode mutation are explicit unsupported control outcomes.
202
249
203
250
### VS Code workspace adapter
@@ -254,13 +301,13 @@ Availability is represented across independent axes: compiled inclusion, runtime
254
301
| --- | --- |
255
302
| Application-home bootstrap and authentication | Operational: a nonblank `AGENTX_HOME`, otherwise `~/.agentx`; this is the sole supported override. One physical home plus `sessions/` is frozen before full CLI parsing; every invocation requires `auth.json`, including malformed input, while model-backed starts strictly parse its version-1 document as their sole model credential source. POSIX ownership/mode enforcement is operational; Windows credential loading is unavailable without native DACL verification. |
256
303
| Azure Responses + `gpt-5.6-sol`| Operational on supported POSIX platforms when the required application-home `auth.json` is private and schema-valid. |
257
-
| Headless text and aggregate JSON | Operational over the shared engine. |
304
+
| Headless text and aggregate JSON | Operational over the shared engine; separate additive session list/delete flags use a provider-free text or one-object JSON management adapter. |
258
305
| Local diagnostic logging | Operational: credential-filtered JSON records use stderr; routine turn start/success records are DEBUG, WARN/ERROR conditions remain eligible at the default INFO threshold, and `-d`/`--debug` adds bounded turn-correlated lifecycle records plus session, model-iteration, stream, retry, capability, usage, timing, and terminal metadata without payload content. Retry warnings carry session and model identity. With persistence enabled, durable lifecycle evidence remains in the transcript independently of logger level whenever append and flush succeed. |
259
306
| Bidirectional NDJSON | Partial: correlated controls and bounded priority queues are operational; in-flight prompt/context injection and several live initialization/mutation controls are unavailable. |
260
-
| VS Code workspace extension | Partial: Activity Bar chat, streaming, tool/result projection, permissions/questions, workspace-scoped sessions, editor references, Restricted Mode gating, diagnostics, and target VSIX packaging are operational; attachments, authoritative session inventory/history replay, live runtime mutation, remote AgentX transport, IDE MCP/LSP bridging, and native qualification of every packaged platform are unavailable. |
307
+
| VS Code workspace extension | Partial: Activity Bar chat, streaming, tool/result projection, permissions/questions, workspace-scoped sessions, editor references, Restricted Mode gating, diagnostics, and target VSIX packaging are operational. The runtime CLI now owns authoritative inventory/deletion, but this change does not integrate it into or modify the extension's lossy presentation cache; attachments, authoritative inventory/history replay in the extension, live runtime mutation, remote AgentX transport, IDE MCP/LSP bridging, and native qualification of every packaged platform are unavailable. |
261
308
| Interactive terminal | Partial: a terminal-safe line REPL is operational; retained rendering, rich editor state, and the full terminal engine are unavailable. |
| MCP stdio client | Partial: lifecycle, tool discovery/calls, generation fencing, and result normalization are operational; media forwarding and fingerprint-bound project approval are unavailable. |
0 commit comments