docs: add expansion roadmap and workflow baseline

This commit is contained in:
faumaray committed 2026-11-24 02:04:38 +03:00
1 parent f1f9ba375b
commit faa8a5198d
65 files changed
+9292

No files matched your search

+123
View File
@@ -0,0 +1,123 @@
# Stacktrace — bounded diagnostics with explicit capabilities
Status: plan; feature tasks PLANNED. Baseline `f1f9ba375b22abf1adcc7c550ec21ac20895c0a4`.
Supports R-003/R-006/R-012/R-014 under [C-01–C-05 and C-11](../ARCHITECTURE.md).
## Existing surface and limits
[Stacktrace.hpp](../../../include/Void/Stacktrace/Stacktrace.hpp) exposes
`Void::Stacktrace::StackFrame`, `capture_stacktrace(skip_frames, max_frames)`,
`read_source_snippet`, `format_stacktrace` and `print_stacktrace`. Capture defaults to
32 frames; each frame owns function/source/snippet strings. Source reads return Result,
whereas capture returns a vector and suppresses exceptions. [Stacktrace.cpp](../../../src/Stacktrace/Stacktrace.cpp)
uses Boost.Stacktrace/demangle, resolves source locations and reads snippets during capture,
then logs diagnostics. [module.cmake](../../../src/Stacktrace/module.cmake) selects
Boost's addr2line backend on the Unix branch and windbg on Windows, depends on Functional
and LogState, and applies Unix debug/frame-pointer flags.
There is no `tests/standalone/Stacktrace` directory in the inspected baseline. Integration
through [Testing's signal handler](../../../src/Testing/SignalHandler.cpp) invokes capture
and formatting on a fatal signal. Existing allocation, file IO, demangling and logging are
not an async-signal-safe crash facility. The plan must not market that path as safe recovery
of a corrupted C++ process. [Testing](Testing.md) owns the replacement crash-isolation policy.
## Selected backend and NEW API
Retain the existing Boost backend initially behind a Void-owned capability interface;
do not add a new unwinding dependency or promise equivalent symbols on every build.
Split raw address capture from optional symbol/source enrichment. A standard-library
backend is a later M-STACKTRACE-05 gate after toolchain feature probes and conformance,
not an assumed C++26 implementation capability. None of this becomes a foundation dependency.
NEW illustrative surface in the existing namespace:
```cpp
struct CaptureOptions { unsigned skip = 0; unsigned max_frames = 32; };
struct ResolveOptions { bool source_snippets = false; std::size_t max_bytes = 64 * 1024; };
struct RawTrace; // owning addresses plus module identity snapshot
struct ResolvedTrace; // bounded frames, incomplete flag, per-frame status
struct Capabilities; // raw capture, symbols, line info; no signal-safety inference
Result<RawTrace> capture(CaptureOptions);
Result<ResolvedTrace> resolve(const RawTrace&, ResolveOptions);
Capabilities capabilities() noexcept;
```
The legacy capture adapter composes capture/resolve using its historical presentation
until the major release. NEW capture does not read source or emit through Log; an optional
diagnostic hook belongs above the low-level path to avoid recursive logging/stacktrace
failures. Unsupported line information is an explicit per-frame result, distinct from
an empty stack, permission-denied source read, or a failed unwinder.
Capture snapshots addresses and module identifiers before a plugin generation can unload.
A trace needed for later resolution either retains that generation or owns sufficient
module/build-id metadata for an explicitly configured offline symbol resolver. Raw addresses
alone are not stable identities across unload, ASLR or process restart. Do not retain a
pointer to a transient loader structure. A synchronous embedded resolver is the default;
managed deferred symbolization uses caller-supplied execution and bounded admission, not a
global worker implicitly started by `capture`.
## Dataflow, bounds and failures
1. Validate skip/count and capacity before unwinding; cap NEW calls at 256 frames and
return InvalidArgument above that limit. Capture may return a valid truncated trace
with an explicit flag when the stack is deeper.
2. Copy module identity/address records to owned storage. Resolve symbols outside any
application registry or logging lock. Resolve failures preserve raw frames for diagnosis.
3. Source snippets are opt-in and constrained to caller-provided allowed roots. Defaults:
three context lines, 4 KiB per snippet, 64 KiB total rendered output, 1 MiB source-file
scan budget. Enforce overflow-safe line arithmetic, maximum line length and file-read
limits; reject unsafe paths and symlink escapes through the configured file-access port.
4. A NEW resolver cache holds at most 1,024 entries/4 MiB and keys by module identity and
address offset. Invalidated module identities cannot reuse stale symbol entries. Default
managed resolution admits 32 jobs/2 MiB total pending trace input with one worker.
5. Cancellation/deadline is checked between frames/source reads. The terminal result owns
completed frames and indicates Partial/Cancelled; it never frees buffers still used by
a backend. Blocking symbol-tool calls require a bounded child-process boundary if that
backend cannot otherwise be interrupted.
Source paths, snippets and module names may reveal private build information. Default
rendering removes configured source-root prefixes and omits snippets. Explicit diagnostic
configuration enables them; telemetry must not attach arbitrary source text automatically.
No debug source file is opened merely because untrusted input names it.
The initial crash path is subprocess test isolation: the parent records exit/signal and
optional externally captured diagnostics. A NEW minimal fatal-signal marker may write a
fixed-size record to a preopened descriptor using a reviewed platform-safe implementation,
but it does not call the rich Stacktrace API or resume the failed process. A fully signal-safe
unwinder is outside this phase and requires a separate safety/capability gate.
## Ordered backlog
| ID | Phase / dependencies | Scope and acceptance | Recommended role |
| --- | --- | --- | --- |
| M-STACKTRACE-01 | P0; existing source and Testing contract | Add direct tests for empty formatting, source failures, frame caps and optional symbols; fixture assertions tolerate stripped builds without hiding failed capture. | sol_implementer |
| M-STACKTRACE-02 | P1; M-STACKTRACE-01, Functional errors | Separate capture/resolve, capability report, remove logging recursion from NEW path; source access is absent by default. | astra_implementer |
| M-STACKTRACE-03 | P2; M-STACKTRACE-02, IO safe file access | Bounded source resolver/cache, redaction, backend timeouts; hostile path/line/size inputs remain within limits. | sol_implementer |
| M-STACKTRACE-04 | P2; M-STACKTRACE-02, Testing subprocess isolation, Plugin generation ownership | Crash integration and deferred lifetime tests; fatal child does not corrupt the test runner and resolution cannot use unloaded code. | astra_implementer |
| M-STACKTRACE-05 | P3; M-STACKTRACE-03/04, supported-toolchain probes | Evaluate standard backend and platform parity using identical tests/profiles; retain Boost unless evidence supports replacement. | astra_implementer |
P4 users consume the same diagnostics through [Observability](../subsystems/Observability.md),
without transmitting full stacks by default. No independent distributed stacktrace service
is required.
## Verification and migration
CURRENT: baseline build and aggregate CTest commands are in [validation](../VALIDATION.md).
There is no current Stacktrace-specific suite to invoke. PROPOSED after M-STACKTRACE-01:
`<configured-build>/tests/VoidTests --filter '^stacktrace_'`; prerequisites include the
new tests, selected Boost backend and a build with known debug information. Test both
stripped and debug fixtures, shared-library unload, invalid UTF/path text, missing source,
huge line number, cancellation and a nonresponsive symbol helper. Never use the current
rich handler itself as proof of signal safety.
[Performance](../PERFORMANCE.md) separates raw capture, symbol resolution, cold/warm cache,
source IO and formatting; report p50/p95/p99, allocations, RSS/CPU and build/debug-symbol
size using the common repetition and regression rules. Measure disabled hooks separately.
[Migration](../MIGRATION.md) retains current names through adapters and documents the new
default of no source reads. Consumer examples transition from `capture_stacktrace()` to
checked `capture()` and optional `resolve()`. Rollback restores the legacy normal-context
presentation adapter, never the unsafe promise of surviving fatal signals. Package tests
in [build/distribution](../BUILD-AND-DISTRIBUTION.md) verify optional backend linkage and
minimal consumers. Cited files have checked graph coverage and direct source verification;
no Stacktrace test or performance result was executed for this plan.