Skip to content

Phase 3d: add actionable configuration parse errors#641

Open
MGudgin wants to merge 1 commit into
mainfrom
user/gudge/versioning_phase3d_actionable_parse_errors
Open

Phase 3d: add actionable configuration parse errors#641
MGudgin wants to merge 1 commit into
mainfrom
user/gudge/versioning_phase3d_actionable_parse_errors

Conversation

@MGudgin

@MGudgin MGudgin commented Jul 13, 2026

Copy link
Copy Markdown
Member

This PR adds actionable configuration parse errors: the parser reports
malformed JSON separately from typed policy-shape errors and includes the full
policy path plus whole-file source location in every diagnostic, without leaking
secrets or letting untrusted text corrupt diagnostics or the state-aware stdout
response envelope.

Details

  • New config_deserialize module: a path-aware deserialize layer that
    distinguishes JSON syntax errors from typed policy errors, attaching the full
    JSON path and whole-file line/column, escaping control and invisible
    formatting characters (incl. U+2028/U+2029 and bidi overrides), and redacting
    secret-bearing values.
  • State-aware per-backend per-phase configs deserialize positionally from the
    retained request text, so typed errors carry whole-file coordinates matching
    base-config errors; navigation uses owned-key maps so escaped sibling keys
    never silently drop the location, with graceful fallback to the value-based
    path.
  • Request loading borrows RawValue to discriminate one-shot vs state-aware
    without building a full untyped AST, masking the experimental subtree to
    preserve base-config source locations.
  • Diagnostic routing keeps stdout reserved for the state-aware envelope and
    script output; parse and dispatch errors go to auxiliary sinks (log file /
    diagnostic pipe) only and are emitted exactly once. Filesystem-path and
    schema-version diagnostics escape untrusted text via the shared
    escape_diagnostic_text helper.
  • Exec dispatch drops the parsed request (and its retained source text) before
    the blocking child run and stdio relay.
  • Docs updated: docs/versioning.md, the state-aware API doc, and the
    copilot-instructions config-flow description.

Tests

  • Added parser coverage: syntax-vs-typed classification, whole-file line/column
    (computed, not hardcoded), escaped-sibling-key location preservation, exact
    column, CRLF line stability, positional secret redaction, source-present
    locator fallback, malformed-telemetry single auxiliary emission with an empty
    primary buffer, and a pinned serde_json positioned-error display-suffix
    contract.
  • cargo fmt --all -- --check: passed.
  • cargo clippy -p wxc_common -p wxc --all-targets -- -D warnings: clean.
  • cargo test -p wxc_common -p wxc: 514 + 26 passed.
  • node scripts/versioning/check-schema-codegen.js,
    check-sdk-types-codegen.js, check-schema-versions.js: passed.

@MGudgin
MGudgin requested a review from a team as a code owner July 13, 2026 22:05
Base automatically changed from user/gudge/versioning_phase3c_three_axis_docs to main July 14, 2026 18:12
@MGudgin
MGudgin force-pushed the user/gudge/versioning_phase3d_actionable_parse_errors branch from 582b133 to 7c288be Compare July 14, 2026 18:25
Copilot AI review requested due to automatic review settings July 15, 2026 17:52
@MGudgin
MGudgin force-pushed the user/gudge/versioning_phase3d_actionable_parse_errors branch from 7c288be to fdf1f96 Compare July 15, 2026 17:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a path-aware JSON deserialization layer to produce more actionable configuration parse errors (policy path + source location), while preserving the state-aware stdout envelope contract by routing parse/dispatch diagnostics only to auxiliary sinks.

Changes:

  • Introduces config_deserialize to distinguish JSON syntax errors vs typed policy-shape errors, including full JSON paths, source locations, control-character escaping, and secret-value redaction.
  • Refactors request loading/discrimination to borrow RawValue for state-aware discrimination (avoids building a full untyped JSON AST) and preserves byte/line locations by masking the experimental subtree.
  • Adjusts logger + state-aware driver behavior to keep stdout reserved for envelopes/script output and avoid duplicating state-aware errors into primary stderr/buffer output.
Show a summary per file
File Description
src/core/wxc/src/main.rs Logs state-aware dispatch errors only to auxiliary diagnostic sinks before emitting error envelopes.
src/core/wxc_common/src/wire.rs Improves root-shape error messaging (expecting) and documents optionality expectations for experimental.
src/core/wxc_common/src/state_aware_request.rs Uses path-aware deserialize for per-backend phase configs and prefixes errors with experimental.<backend>.<phase>.
src/core/wxc_common/src/state_aware_dispatch.rs Extends tests to assert envelope-ready error paths for typed state-aware backend configs.
src/core/wxc_common/src/logger.rs Adds log_diagnostic_line to write only to auxiliary sinks (file/diagnostic pipe), and refactors log_line accordingly.
src/core/wxc_common/src/lib.rs Wires in the new internal config_deserialize module.
src/core/wxc_common/src/config_parser.rs Refactors request parsing/logging, adds RawValue discriminator + experimental masking for location preservation.
src/core/wxc_common/src/config_deserialize.rs New: central path-aware deserialize + formatting/redaction/escaping for diagnostics.
src/core/wxc_common/Cargo.toml Enables serde_json raw_value support and adds serde_path_to_error.
src/Cargo.toml Adds workspace dependency on serde_path_to_error.
src/Cargo.lock Locks serde_path_to_error.
docs/versioning.md Documents the new “actionable parse errors” behavior and guarantees.
docs/state-aware-lifecycle/mxc-state-aware-sandbox-api.md Documents auxiliary-only routing for state-aware parse-phase failures.
.github/copilot-instructions.md Updates documented config flow to include config_deserialize.

Review details

  • Files reviewed: 13/14 changed files
  • Comments generated: 2
  • Review effort level: Low

Comment thread src/core/wxc_common/src/config_parser.rs Outdated
Comment thread src/core/wxc_common/src/config_deserialize.rs
@MGudgin
MGudgin force-pushed the user/gudge/versioning_phase3d_actionable_parse_errors branch 2 times, most recently from aec0002 to cf263ca Compare July 15, 2026 20:36
Comment thread src/core/wxc_common/src/config_parser.rs Outdated
Comment thread src/core/wxc_common/src/state_aware_request.rs
@MGudgin
MGudgin force-pushed the user/gudge/versioning_phase3d_actionable_parse_errors branch 4 times, most recently from deb054c to 14bd6cb Compare July 23, 2026 00:50
This PR adds actionable configuration parse errors: the parser reports
malformed JSON separately from typed policy-shape errors and includes the
full policy path plus whole-file source location in every diagnostic,
without leaking secrets or letting untrusted text corrupt diagnostics or
the state-aware stdout response envelope.

Details

* New config_deserialize module: a path-aware deserialize layer that
  distinguishes JSON syntax errors from typed policy errors, attaching the
  full JSON path and whole-file line/column, escaping control and invisible
  formatting characters (incl. U+2028/U+2029 and bidi overrides), and
  redacting secret-bearing values.
* State-aware per-backend per-phase configs deserialize positionally from
  the retained request text, so typed errors carry whole-file coordinates
  matching base-config errors; navigation uses owned-key maps so escaped
  sibling keys never silently drop the location, with graceful fallback to
  the value-based path.
* Request loading borrows RawValue to discriminate one-shot vs state-aware
  without building a full untyped AST, masking the experimental subtree to
  preserve base-config source locations.
* Diagnostic routing keeps stdout reserved for the state-aware envelope and
  script output; parse and dispatch errors go to auxiliary sinks (log file /
  diagnostic pipe) only and are emitted exactly once. Filesystem-path and
  schema-version diagnostics escape untrusted text via the shared
  escape_diagnostic_text helper.
* Exec dispatch drops the parsed request (and its retained source text)
  before the blocking child run and stdio relay.
* Docs updated: versioning.md, the state-aware API doc, and the
  copilot-instructions config-flow description.

Tests

* Added parser coverage: syntax-vs-typed classification, whole-file
  line/column (computed, not hardcoded), escaped-sibling-key location
  preservation, exact column, CRLF line stability, positional secret
  redaction, source-present locator fallback, malformed-telemetry single
  auxiliary emission with an empty primary buffer, and a pinned
  serde_json positioned-error display-suffix contract.
* cargo fmt --all -- --check: passed.
* cargo clippy -p wxc_common -p wxc --all-targets -- -D warnings: clean.
* cargo test -p wxc_common -p wxc: 514 + 26 passed.
* node scripts/versioning/check-schema-codegen.js,
  check-sdk-types-codegen.js, check-schema-versions.js: passed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Generated-with: gpt-5.6-sol
Generated-with: claude-opus-4.8
Copilot-Session: dd87e65c-7e38-4d0e-8238-147c2153a0e8
@MGudgin
MGudgin force-pushed the user/gudge/versioning_phase3d_actionable_parse_errors branch from 14bd6cb to e30ac71 Compare July 23, 2026 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants