140 lines
8.4 KiB
Markdown
140 lines
8.4 KiB
Markdown
# Architecture and shared invariants
|
|
|
|
Status: approved design; most components below are PLANNED. Milestone0 implements
|
|
only CLI, framing, JSON adapter and lifecycle. See README and verification records
|
|
for actual completion. NEW record names below are design contracts, not existing APIs.
|
|
|
|
## Data and control flow
|
|
```mermaid
|
|
flowchart LR
|
|
E[Neovim / VS Code] --> L[LSP session]
|
|
L --> D[Versioned document store]
|
|
V[VBS manifest / compilation database] --> C[Build contexts]
|
|
D --> Q[Foreground scheduler]
|
|
C --> Q
|
|
Q --> W[Isolated semantic workers]
|
|
W --> I[Context-aware index]
|
|
I --> L
|
|
W --> L
|
|
E --> A[DAP control + read-only inspection]
|
|
A --> S[Debug session service]
|
|
D --> S
|
|
C --> S
|
|
S --> X[Isolated instrumented compiler]
|
|
X --> T[Trace + captured values]
|
|
T --> S
|
|
```
|
|
|
|
One editor workspace launches one server instance initially; there is no shared
|
|
multi-client daemon. DAP adapters connect only to their corresponding private
|
|
session service through authenticated/inherited local IPC. Transport details must
|
|
preserve workspace/session identity and never expose an unauthenticated TCP listener.
|
|
|
|
## Shared records
|
|
| NEW record | Owner | Required meaning |
|
|
| --- | --- | --- |
|
|
| DocumentSnapshot | documents | URI, text, monotonic client version, content identity, line/encoding map |
|
|
| BuildContext | build model | provider/context/target/profile identities, exact semantic arguments, toolchain, readiness |
|
|
| AnalysisRevision | scheduler | document + context + build generation + dependency identities + backend version |
|
|
| ToolingGeneration | VBS provider | complete immutable export, selection revision and retained artifact references |
|
|
| SemanticRequest / Result | workers | capability, revision, payload/provenance, cancellation and typed failure |
|
|
| SymbolIdentity / SourceOrigin | index/reflection | declaration identity, context membership and editable/generated origin chain |
|
|
| DebugSession | debug service | frozen snapshots/context, launch selection, state, resource allowance |
|
|
| EvaluationEvent / CapturedValue | instrumentation | ordered event, causal parent, source origin, typed event-time state |
|
|
| TraceManifest | replay | schema/backend/source/context identities, committed events and terminal status |
|
|
| InspectionHandle | debug service | session + snapshot + stop/replay generation; no raw compiler pointer |
|
|
|
|
Root serializes shared schemas and version changes. Freeze each interface before
|
|
dependent parallel coding. Schema migration failures preserve old artifacts and
|
|
report incompatibility rather than reinterpret bytes.
|
|
|
|
## Source state and build state
|
|
Disk content, unsaved editor buffers, generated views and physical VBS snapshots
|
|
are different namespaces. Every request uses immutable snapshots. Result publication
|
|
checks the complete AnalysisRevision, including header/import changes and backend.
|
|
A stale last-good context may support explicitly degraded read-only queries;
|
|
rename requires fresh metadata, complete declared coverage and editable origins.
|
|
|
|
VBS retains all configured targets/command alternatives even if a build selects a
|
|
subset. Follow its editor profile; a per-file target override never merges flags.
|
|
Host build-description compilation is a separate context from target code.
|
|
|
|
Native VBS export uses immutable local manifests plus an atomic selection reference.
|
|
The producer must supply versions, identities, semantic environment, source mappings,
|
|
module/prerequisite metadata, freshness/readiness and retention rules. Consumers
|
|
cannot infer readiness from path existence. Bootstrap vbs_describe is insufficient.
|
|
Initially configure an explicit manifest locator; automatic discovery is introduced
|
|
only with a versioned producer contract, not a guessed hidden-file convention.
|
|
|
|
Compdb supplies commands, not equivalent generation/module/provider metadata.
|
|
Prefer arguments; parse command quoting without a shell. Expand response files with
|
|
the declared driver's grammar, bounded recursion and content identity. Never string-
|
|
replace paths inside arbitrary flags/macros to create snapshot/editor projections.
|
|
|
|
## Execution authority
|
|
Only configured, identity-verified toolchain/VBS executables may be launched.
|
|
Repository configuration and compdb argv[0] cannot grant trust. Arbitrary plugins
|
|
and unapproved wrappers are unsupported in v1; inspect expanded execution-bearing
|
|
options before dispatch and fail explicitly rather than remove semantic options.
|
|
Trusted metadata refresh is distinct from generators, dependency builds, fetches
|
|
and lock updates. Private IDE BMIs do not authorize project build actions.
|
|
Compiler isolation improves recovery; it is not a security sandbox.
|
|
|
|
## Modules and reflection
|
|
Use compiler-proven dependency scans plus VBS metadata; never regex module discovery
|
|
as semantic authority. BMIs/PCHs belong to the exact backend/options/input identity,
|
|
including transitive dependencies and relevant physical paths. No GCC-to-Clang
|
|
binary artifact reuse. Overlay edits rebuild dependent private IDE artifacts.
|
|
Generated declarations preserve origin chains. A displayed generated source is a
|
|
read-only explanation of semantic structure, not necessarily compilable source text.
|
|
Unknown origin prevents destructive edits; it does not erase the entity from navigation.
|
|
|
|
## Index and rename
|
|
The index partitions results by semantic context and committed generation.
|
|
Publication is atomic at the index-generation level; failed/cancelled work is not
|
|
promoted. Persistent schema/backend mismatches rebuild into a new generation.
|
|
|
|
Rename coverage is all declared workspace roots and every provider-exported context
|
|
that can bind the affected files/symbols, including inactive profiles/targets.
|
|
It does not claim to cover unknown external consumers or all hypothetical defines.
|
|
Analyze missing contexts on demand; conflicts, missing generated origins or unknown
|
|
coverage reject the rename. Both supported clients open/synchronize affected files
|
|
before recomputation, validate versions/content and apply a tested transactional
|
|
buffer edit. Without that behavior, refuse multi-file edits. File saving and external
|
|
disk conflict detection remain editor responsibilities; no filesystem atomicity claim.
|
|
|
|
## Debugger state and replay
|
|
Select a translation unit/context and an existing evaluation/source point or concrete
|
|
template instantiation; do not invent arbitrary template arguments silently.
|
|
States: preparing, running, stopped, replaying, completed, failed, cancelled, expired.
|
|
A session freezes source/context; later edits mark it outdated until restarted.
|
|
DAP is the only execution-control ingress. Custom views issue read-only versioned
|
|
queries against the same service. Each movement invalidates earlier inspection handles.
|
|
Captured values must represent event-time state, with bounded structural serialization,
|
|
cycles/opaque values handled explicitly. Compiler pointers never become persisted IDs.
|
|
Replay moves a cursor over stored state and cannot mutate historical target execution.
|
|
Live step-back/time-travel mutation is not a v1 requirement.
|
|
|
|
Initial limits per server instance: one live session,2GiB worker RSS,3GiB aggregate
|
|
debug-service memory,256MiB/1M-event trace,60s running CPU,120s running wall time,
|
|
30min paused idle,5s disconnect grace. Enforce admission before start; reject debug
|
|
startup if required enforcement is unavailable. Exclude deliberate pause from running
|
|
watchdogs, but count its memory. Cancellation/expiration terminates and reaps owned
|
|
process groups; committed trace prefixes remain explicitly incomplete.
|
|
|
|
## Bootstrap JSON gate
|
|
Follow VoidLibrary main per D-021 and record the exact tested commit. Accept its
|
|
decimal update only after tests cover number grammar,
|
|
ID preservation, controls, raw UTF-8, escaped surrogate pairing and depth limits.
|
|
The VLS adapter supplies only remaining protocol/boundary validation; it must not
|
|
call an unbounded recursive decoder before validating depth or substitute the old
|
|
integer-only parser. Upstream code changes belong to its worker, not this repository.
|
|
|
|
## Delivery and review
|
|
Milestone0 remains independent of compiler/VBS implementations except the JSON gate.
|
|
Gate1 proves real GCC-context semantics; Gate2 proves actual compiler instrumentation
|
|
and live/replay behavior. Failed gates stop dependent tasks and preserve evidence.
|
|
Root owns contracts/pins/integration; Sol owns bounded packages, Astra coupled
|
|
compiler/module/debug work. Fresh preflight/final review and affected behavior checks
|
|
are required for each substantial wave. Detailed proposed ownership is in each plan.
|