Files
marqdo-cli/docs/developers/analysis-observation.md
T
cflmy d11b261aca docs: make the current contracts describe the binary that exists
- spec/security.md: replace the retired --json/EffectTrace/--trace-file
  sections with the current strict output contract (text or one snapshot from
  the verified child, live/file destinations refused) and Observation effect
  events; drop the deleted trace.rs implementation row.
- spec/package-format.md, spec/value-wire.md, spec/evaluation.md,
  spec/resource-provider-v2.md, spec/foreign.md: describe the current
  --output/--observation-file and Observation events instead of run/call
  --json and Execution Events.
- spec/analysis.md: a load failure removes the previous artifact, not only a
  compile error.
- COMPATIBILITY.md and docs/developers/*: current axes are Analysis v3,
  Observation v1 and CLI Tool revision 1; Rust 1.89; rc.3 candidate status.
- Fix the Analysis v2 / Trace v2 / trace-file references in README,
  architecture overview, contributor guide, tool example, source comments and
  AGENTS.md.
- Add a docs-consistency gate that fails when spec/ or the current developer
  guides document a retired interface or a deleted spec path.
2026-11-24 20:57:13 +08:00

45 lines
2.0 KiB
Markdown

# Analysis and Observation
Run the same public CLI that users install.
```sh
marqdo check index.mq.md --emit ./analysis.json
marqdo call index.mq.md main --output jsonl --observation-file ./run.json
```
A tool can use [Analysis](../../spec/analysis.md) to locate functions, imports,
references, resources and calls. Validate its identifier before walking the
module and statement arrays. Use the original UTF-8 bytes for offsets and
digest checks. The format is the same for a simple document and one using
structured loop transfers.
[Observation](../../spec/observation.md) carries frames, control flow, committed
output and the final result. Consume JSONL for live updates, or use
`--output json` for one JSON snapshot on stdout. The snapshot's `events`
array has the same objects as the live stream. The first event opens the run
and the terminal event gives its outcome. Treat a stream that ends before a
terminal as incomplete. Base64 decode each stdout and stderr chunk and verify
its byte count. Read the typed return from `run.completed.payload.value`.
Before highlighting source locations, compare the `run.started` root and
SHA-256 of the exact Analysis artifact, then check the source file digest.
A different report or edited source requires a fresh check and run.
The repository's independent consumer implements both delivery modes.
```sh
python3 tests/consumers/observation_consumer.py ./run.json --snapshot \
--analysis ./analysis.json --source-root .
```
Value capture uses exact names and explicit Text consent. Use
`--observe-variable NAME` and `--observe-parameter NAME` only for the
values the feature needs. Request `--observe-text-values` when the caller
has opted into this disclosure. Program output and explicit returned values
can themselves contain sensitive data.
Update integrations that previously used the retired run/call JSON,
Trace, Execution Events or retired run/call options. Use the commands above,
remove the old
reader, and rebuild and reinstall the Tool with the
[current manifest](../../spec/cli-tool.md).