Skip to content

feat(signals): decode recorded logic signals through sigrok - #2126

Closed
Olorinm wants to merge 8 commits into
morluto:mainfrom
Olorinm:feat/recorded-signals
Closed

Olorinm wants to merge 8 commits into
morluto:mainfrom
Olorinm:feat/recorded-signals

Conversation

@Olorinm

@Olorinm Olorinm commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Add decode_signal_recording / decode-signal-recording for an analyst who already has a logic-analyzer recording and wants protocol-decoder annotations in REA Evidence. For example, a UART VCD plus uart:rx=RX:baudrate=9600 yields sample ranges and decoded display text through the same CLI/MCP workflow.

Problem and expected behavior

REA can investigate firmware but cannot currently interpret recorded digital signals. The separate packet-capture proposal #2130 is independent and can be reviewed or merged separately. This additive capability delegates decoding to caller-supplied sigrok-cli 0.7.2, preserves the selected decoder/channel/options and producer diagnostics, and works without opening a binary target. There is no linked issue; this PR proposes that focused enhancement for review.

Change and scope

One file-analysis tool, an optional sigrok adapter, shared application validation/Evidence, CLI/MCP registration, capability/catalog entries, a guide, canonical README capability rows in every translation, and authored skill guidance. No physical acquisition, device control, installer, native-analysis changes or automatic protocol guessing.

Contract and boundary impact

  • Semantic owner and earliest changed stage: strict signal-recording schemas; sigrok adapter owns producer arguments and output. The shared service validates artifact identity and exact selections before creating Evidence.
  • CLI and MCP/tool-catalog contract: additive named contract; required path and decoder selection; optional input format and annotation selector; inline typed Evidence.
  • Provider, bridge, target-format, or platform compatibility: absolute REA_SIGROK_COMMAND, sigrok-cli 0.7.2 with libsigrokdecode. Linux with util-linux prlimit is required; unsupported hosts fail before workspace allocation. REA_SIGROK_PRLIMIT_COMMAND can override /usr/bin/prlimit.
  • Evidence, artifact, provenance, or reconstruction contract: source digest/size/path, configured and resolved executable/limiter paths, digests and arguments, tool version, verbatim annotation text, decoding stderr and separate version-probe diagnostics. Sample ranges are not recast as timestamps or lossless binary payloads. Empty output does not prove no traffic.
  • Process execution, authorization, cleanup, or containment impact: private read-only input copy, owned process supervision, cancellation, 30-second command deadline, 32-MiB input and 4-MiB combined output bounds. Overflow fails; cleanup failure retains ownership and completed observations for retry. The one-shot CLI awaits a close retry without masking the original failure; MCP records completed partial Evidence before error delivery, and bounded post-run identity checks complete before honoring a late abort. Before launch, prlimit enforces soft and hard limits of at most 1 GiB address space, 64 MiB per file, 30 CPU seconds and no core dumps. Stricter inherited soft/hard limits are preserved and effective values are reported. These are per-process/per-file limits, not aggregate quotas or an OS sandbox; caller tools/modules and the limiter are trusted. Workspace failures are distinguished from invalid input. Post-run identity errors identify the private copy/tool/limiter involved and retain captured output. Resource-signal failures retain the signal and effective limits without claiming the signal proves its cause.
  • Generated metadata, package, or installation impact: source catalog registration only; generated outputs are ignored. No dependency, package or installation changes.

Evidence and regression coverage

  • Tests added: command-boundary coverage of warnings/options, immutable snapshot verification, nonzero exit, output overflow, cancellation, cleanup retry and pre-admission validation, and completed observations on late cancellation; workspace failures, unsupported hosts, advertised MCP schemas and unavailable-tool diagnostics. A Linux kernel test verifies inherited hard/soft limits and refused allocation with a synthetic producer; this is separate from real sigrok coverage. A second Linux process test confirms lower inherited file/CPU limits are preserved during the actual launch.

  • Executed real evidence: synthesized 9600-baud 8N1 UART recording carrying REA produces annotations for 52, 45, 41 with sample ranges. CLI/MCP return the same Evidence ID; stored Evidence and source identity are checked.

  • Real verifier also exercises format autodetection, annotation selection, invalid decoder, absent/malformed recording and rejected extra arguments. No remaining owned descendants.

  • Remaining proof gaps: other decoders/formats and physical hardware. macOS and Windows are explicitly unsupported. The real provider and Linux kernel-limit checks run in the linked fork workflow below; upstream CI remains visible under Checks; the links below are independently executed fork verification.

  • Observed, derived, and inferred claims remain distinguishable.

  • Artifact identity, source provenance, and failed attempts remain preserved.

  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npm run check — passed (existing repository lint warnings remain).
  • npm run docs:check — passed.
  • npm run verify:test-discovery — all 920 test files discovered exactly once.
  • Focused provider/MCP, capability and product-catalog tests — 50 passed on macOS, two Linux-only kernel tests skipped.
  • Linux workflow on 847c7cc67 — passed: 26 provider/CLI/MCP/resource-limit tests, plus 6 real sigrok CLI/MCP cases on Ubuntu 24.04 (sigrok-cli 0.7.2, libsigrok 0.5.2, libsigrokdecode 0.5.3). Kernel tests verify refused oversized allocation and preservation of lower inherited file/CPU limits.
  • git diff --check and staged-diff Gitleaks scan — passed.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: no changes to those providers. This new adapter supports Linux only; earlier macOS verification does not establish the current bounded integration.
  • Package or release metadata impact: none.
  • Security/privacy/containment: the selected recording, producer/limiter identities and diagnostics enter Evidence; ambient environment is not serialized. Recordings may contain sensitive data and their selected content is preserved. Source is never passed to sigrok; libraries/modules remain trusted and uncontained.

Review checklist

  • Concrete enhancement; one focused outcome and Conventional Commit title.
  • Reason for no linked issue stated above.
  • Changed public behavior and meaningful failure paths covered.
  • Owning docs, contracts and catalog sources updated.
  • Representative CLI/MCP result and actual validation stated.
  • Final diff checked for secrets, unrelated changes and unsupported claims.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-12T11:48:40.837612Z 847c7cc New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dccb8024ce

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +136 to +139
{
timeoutMs: LIMITS.command_timeout_ms,
diagnosticBytes: LIMITS.output_bytes,
acceptNonZeroExit: true,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Bound decoder expansion before launching sigrok

For archive-backed formats accepted by sigrok, the 32 MiB input cap does not bound expanded data, and this runOwnedCommand configuration limits only time and diagnostic output; the provider's own limitation confirms that child heap and format expansion remain unbounded. A small selected recording can therefore make sigrok exhaust host memory before the timeout, so enforce an address-space/heap limit or preflight and reject formats whose expansion cannot be bounded.

AGENTS.md reference: AGENTS.md:L46-L46

Useful? React with 👍 / 👎.

Comment thread docs/signal-recordings.md
libsigrokdecode. It does not acquire samples or communicate with hardware.

```sh
export REA_SIGROK_COMMAND=/absolute/path/to/sigrok-cli

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Add the signal provider to the canonical README inventory

Although this introduces the only setup instruction for REA_SIGROK_COMMAND, a repo-wide search finds no signal/sigrok entry or guide link in README's supported-target and provider sections. Users following the repository's canonical provider setup inventory therefore cannot discover this feature or its configuration, so add a README inventory entry linking this guide.

AGENTS.md reference: AGENTS.md:L5-L5

Useful? React with 👍 / 👎.

LIMITS.input_bytes,
options?.signal,
);
await writeFile(snapshotPath, selected.bytes, {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Separate workspace write failures from invalid input

When the source read succeeds but this write fails because the temporary filesystem is full, phase is still artifact, so #failure returns an AnalysisInputError against input.path; an EACCES here is likewise reported as access denial on the source path. This tells callers to change a valid recording and loses the actual workspace/resource cause, so distinguish snapshot-write failures and map them to a resource or provider error.

AGENTS.md reference: AGENTS.md:L25-L25

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 619832f9d0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/server/registerSignalTools.ts Outdated
withAdmittedAnalysis?: WithAdmittedAnalysis,
): void => {
const contract = toolContract("decode_signal_recording");
const handler = createEvidenceToolHandler(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Record completed partial Evidence in MCP sessions

When decoding has already produced Evidence but SignalRecordingService returns it as partialObservation for a late abort or cleanup failure, createEvidenceToolHandler takes its error branch before invoking recordEvidence. In a session this makes get_evidence_bundle omit the completed observation, and a cancelled MCP request may suppress the only inline copy, so bind this tool through a handler that records Evidence partials before projecting the error.

AGENTS.md reference: AGENTS.md:L5-L5

Useful? React with 👍 / 👎.

Comment thread src/cli/signalCommands.ts Outdated
Comment on lines +22 to +24
// The provider cleans each call before returning, including failed calls.
// A second close here could replace a cleanup error carrying partial Evidence.
run: ({ args, options }) =>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Retry retained cleanup before the CLI exits

When decode-signal-recording ends with cleanupIncomplete, the provider deliberately keeps the runtime/process supervisor in service for close() to retry, but this one-shot CLI path never calls close() and discards the only owner as the process finishes. A failed process-group stop can therefore leave the decoder running, and a failed root removal can leave the private recording on disk; retry close while preserving the original projected error/partial Evidence instead of skipping it.

AGENTS.md reference: AGENTS.md:L17-L17

Useful? React with 👍 / 👎.

Comment thread src/signals/SigrokRecordingProvider.ts Outdated
const current = await readStableArtifact(
command,
64 * 1024 * 1024,
options?.signal,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve decoder output during post-run cancellation

If cancellation arrives after runOwnedCommand has returned the decoder output but during this up-to-64 MiB executable rehash (or the subsequent recording-copy rehash), passing the aborted signal makes readStableArtifact throw before output can be returned and #failure emits a bare cancellation. The already captured annotations/stderr are then absent even from capturedOutput; retain that snapshot or finish the bounded integrity checks before honoring the late abort.

AGENTS.md reference: AGENTS.md:L11-L11

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 82d0f2c67a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +424 to +426
"file-size",
reason,
{ input_bytes: LIMITS.input_bytes },

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Scope size-limit errors to the selected input

When the decoder grows the private recording copy past 32 MiB (or the executable/limiter grows past its 64 MiB rehash cap), those producer-phase reads also throw ArtifactReaderFailure("limit"), but this unconditional projection reports the 32 MiB input_bytes bound. The source has already passed admission, so callers are told to replace a valid recording instead of being told that the decoder mutated its copy or that a tool identity changed; gate this mapping to the source-read phase and classify post-run snapshot/tool failures against the actual resource.

AGENTS.md reference: AGENTS.md:L25-L25

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 847c7cc673

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +504 to +507
{
cause,
userMessage: `${reason} On Linux, configure sigrok-cli 0.7.2 through REA_SIGROK_COMMAND and util-linux prlimit through REA_SIGROK_PRLIMIT_COMMAND (default /usr/bin/prlimit).`,
},

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve failed version-probe diagnostics

When the configured executable returns exit 0 for --version but emits an unsupported banner (for example, 0.7.1 or no libsigrokdecode), execute has already placed its stdout/stderr in capturedOutput; this configuration branch keeps only cause, which projectAnalysisError does not expose. Linux CLI/MCP users consequently see only the generic “Expected sigrok-cli...” message and lose the observed banner needed to fix the installation, so pass observedOutput through as capturedOutput.

AGENTS.md reference: AGENTS.md:L11-L11

Useful? React with 👍 / 👎.

@N0zoM1z0 N0zoM1z0 self-assigned this Oct 12, 2026
@N0zoM1z0 N0zoM1z0 closed this Oct 12, 2026
@morluto morluto added the enhancement New feature or request label Oct 14, 2026
@morluto

morluto commented Oct 15, 2026

Copy link
Copy Markdown
Owner

Thanks @Olorinm for adding recorded logic-signal decoding through sigrok. Main now exposes the provider through the shared CLI/MCP workflow and documents its decoder and host requirements (main).

@morluto morluto added the area: runtime Process capture and runtime observation label Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: runtime Process capture and runtime observation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants