Skip to content

7.2.1: Stable JSONL schemas for observe graph-slice#96

Merged
leynos merged 22 commits intomainfrom
codex/7-2-1-graph-slice-execplan
Apr 12, 2026
Merged

7.2.1: Stable JSONL schemas for observe graph-slice#96
leynos merged 22 commits intomainfrom
codex/7-2-1-graph-slice-execplan

Conversation

@leynos
Copy link
Copy Markdown
Owner

@leynos leynos commented Apr 2, 2026

Summary

  • Expanded the stable JSONL observe graph-slice surface with new internal helpers, tests, and wiring across weaver-cards, weaverd, and CLI. Public contract remains serde-annotated and snapshot-testable.
  • Added a dedicated parse helpers module to support argument parsing and validation.
  • Extended test coverage with unit, integration, and behaviour tests, plus updated fixtures and snapshot tests.
  • Wired the graph-slice surface through the daemon/router and CLI discoverability, including end-to-end planning documentation.

Changes

  • New graph_slice surface under crates/weaver-cards:
    • budget.rs, mod.rs, parse.rs, parse_helpers.rs, request.rs, request_tests.rs, response.rs
  • Public surface exposure:
    • graph_slice is publicly exported from weaver-cards and wired through the daemon/router to support observe graph-slice
  • Library wiring:
    • crates/weaver-cards/src/graph_slice/mod.rs (new)
    • crates/weaver-cards/src/lib.rs: re-exports the new graph_slice surface and expands the stable contract to cover observe graph-slice
  • Request/Response surface:
    • GraphSliceRequest, GraphSliceResponse, SliceBudget, SliceDirection, SliceEdgeType, and related error/parse types
  • Helpers:
    • crates/weaver-cards/src/graph_slice/parse_helpers.rs (new)
  • Tests and fixtures:
    • graph_slice_behaviour.rs, graph_slice_fixtures.rs, graph_slice_snapshot_tests.rs
    • GraphSlice request tests: graph_slice/request_tests.rs
    • Snapshot tests for requests/responses and edge serialization
    • Fixtures for deterministic edges/cards
  • Daemon/Router wiring:
    • crates/weaverd/src/dispatch/observe/graph_slice.rs (handler outline) and mod.rs export
    • crates/weaverd/src/dispatch/router.rs: added routing for graph-slice
  • CLI and discoverability:
    • crates/weaver-cli/src/discoverability.rs: graph-slice added to domain operations
    • crates/weaver-cli/src/cli.rs: observe graph-slice surfaced in help output
  • Documentation:
    • docs/execplans/7-2-1-define-stable-jsonl-request-and-response-schemas-for-observe-graph-slice.md
  • End-to-end trajectory planning:
    • ExecPlan document outlining stage-by-stage rollout for stable graph-slice surface

Rationale

  • Establishes a canonical, serde-annotated, stable contract for observe graph-slice (analogous to observe get-card). This provides deterministic JSONL shapes, testable snapshots, and a foundation for later traversal implementations, while keeping traversal/wiring for later milestones.

Plan of work (high level)

  • Stage A: Graph-slice schema surface in weaver-cards (budget, parse, request, response) and re-export
  • Stage B: Unit and snapshot tests for contract stability
  • Stage C: Daemon routing and CLI exposure
  • Stage D: Behavioural tests with rstest-bdd
  • Stage E: End-to-end snapshots with graph-slice fixtures
  • Stage F: Documentation updates
  • Stage G: Validation gates

Notes for reviewers

  • The surface remains contract-only for 7.2.1; full traversal/wire-up to be addressed in later milestones.
  • Edge targets use a stable resolution_scope enum with canonical values (full_symbol_table, partial_symbol_table, lsp).
  • Budget is modeled as a dedicated nested object in both request and response constraints to keep the contract explicit and snapshot-stable.
  • All new surface types are serde-annotated and snapshot-testable to ensure stability across releases.

📎 Task: https://www.devboxer.com/task/265b9025-1af3-4c49-98b6-bb0ed6fcbb98

…chemas for observe graph-slice

This ExecPlan outlines the design, constraints, risks, progress stages, and testing strategy for implementing a stable JSONL request and response schema for the `observe graph-slice` operation. It establishes the contract and expected behavior for downstream consumers, details the schema ownership within `weaver-cards`, and sets the roadmap milestones for defining and testing the feature comprehensively.

No code changes are included; this document guides the upcoming implementation.

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 2, 2026

Overview

This PR implements a stable, serde-annotated JSONL contract for the observe graph-slice surface (contract-only work for milestone 7.2.1). It adds typed request/response schema types, deterministic parsing/validation, CLI discoverability, daemon routing and a handler scaffold that emits a deliberate not-yet-implemented refusal, together with comprehensive unit, snapshot and BDD tests, deterministic fixtures and Insta snapshots. Full traversal implementation and runtime wiring are deferred per the included ExecPlan.

ExecPlan

  • docs/execplans/7-2-1-define-stable-jsonl-request-and-response-schemas-for-observe-graph-slice.md — new ExecPlan prescribing request/response semantics, canonicalisation (ordering/deduplication), spillover behaviour, validation gates and a staged rollout (Stages A–G). The implemented schema, tests and snapshots follow this design document.

Core API & Schema (crates/weaver-cards/src/graph_slice)

  • mod.rs: new top-level module and public re-exports for the graph-slice schema surface.
  • budget.rs: introduces SliceBudget with defaults (DEFAULT_MAX_CARDS = 30, DEFAULT_MAX_EDGES = 200, DEFAULT_MAX_ESTIMATED_TOKENS = 4000) and fluent with_max_* setters; serde fields named max_*.
  • request.rs: defines GraphSliceRequest and GraphSliceError; SliceDirection (default both) and SliceEdgeType (canonical set call/import/config) with canonical_rank and all(); SliceParseError for FromStr failures. GraphSliceRequest::parse handles CLI-style tokens and exposes uri, position (line/column), depth, direction, edge_types, min_confidence, budget and detail levels.
  • parse.rs + parse_helpers.rs: RequestBuilder and Flag enum centralise flag dispatch. parse_helpers introduces RawValue, require_arg_value and typed parsers (parse_uri, parse_position, parse_u32, parse_direction, parse_edge_types, parse_confidence, parse_detail) that produce GraphSliceError::InvalidValue messages attributed to the originating flag. build() validates required fields, applies defaults and normalises/deduplicates edge types into canonical order. The Flag/RawValue refactor reduces stringly-typed arguments and improves error attribution.
  • response.rs: GraphSliceResponse (serde-tagged by status) with Success and Refusal variants; SliceEntry, SliceConstraints (echoed constraints), SliceEdge (with EdgeTarget local/external), EdgeProvenance/CallSiteInfo, ResolutionScope (snake_case), SliceSpillover (with empty() helper) and SliceRefusal/SliceRefusalReason. GraphSliceResponse::not_yet_implemented() convenience constructor provided.

Daemon & CLI integration

  • weaverd:
    • New observe/graph_slice handler: parses arguments via GraphSliceRequest::parse (parsing failures → DispatchError::invalid_arguments), returns GraphSliceResponse::not_yet_implemented(), writes JSON to stdout and maps response variants to exit status (0 success, 1 refusal).
    • Registered "graph-slice" in DomainRouter::route_observe and observe module exports.
    • Tests updated/added to include "graph-slice" in known-operations and invalid-arguments expectations; handler tests capture JSONL stdout and assert the not-yet-implemented refusal payload and parse-error handling.
  • weaver-cli:
    • Added "graph-slice" to DOMAIN_OPERATIONS and help/localisation (en-US messages.ftl) for discoverability.

Tests, Fixtures & BDD

  • Unit tests:
    • request_tests.rs: extensive parsing tests (minimal/full flags), defaults, error paths, edge-type normalisation and deduplication.
    • parse_helpers_tests.rs: direct tests for value-level parsers and require_arg_value.
    • graph_slice_snapshot_tests.rs: Insta snapshots for request parsing and multiple response shapes (default success, truncated/spillover, multi-resolution, refusal variants) plus focused enum/struct serialisation assertions and a small serializer helper.
  • Fixtures:
    • graph_slice_fixtures.rs: deterministic builders for sample_success_response, sample_truncated_response, sample_multi_resolution_response, sample_refusal and sample_constraints; resolved-call and external edge builders.
  • Behaviour tests:
    • graph_slice_behaviour.rs and tests/features/graph_slice_schema.feature: BDD scenarios validating request defaulting/validation, normalisation rules, spillover semantics and resolution_scope serialization.
  • Test utilities:
    • test_utils.rs: shared QuotedString parsing utility used by BDD steps.
  • Daemon handler tests:
    • crates/weaverd/src/dispatch/observe/graph_slice_tests.rs: handler-level tests asserting JSONL stdout payloads and parse-error handling.
  • Test maintenance changes from review:
    • Duplicate unit/snapshot tests were consolidated into parameterised/ thin wrappers and a private assert_serializes_as helper to reduce duplication; parse_helpers tests moved into a separate test module per commit history.

Documentation & Exports

  • crates/weaver-cards/src/lib.rs: exposes pub mod graph_slice and re-exports key types/constants (GraphSliceRequest, GraphSliceResponse, SliceBudget, SliceDirection, SliceEdgeType, DEFAULT_*).
  • docs/developers-guide.md and docs/users-guide.md: describe the parsing architecture, CLI flags and the JSONL contract.
  • Minor markdown/front-matter formatting tweaks (agent-skill/weaver/SKILL.md).

Review notes, applied refactors and design decisions

  • Applied refactors:
    • Centralised value-level parsing in parse_helpers (RawValue + require_arg_value + typed parsers) to standardise invalid-value messages and reduce stringly APIs.
    • Added fluent SliceBudget with_max_* helpers.
    • Decomposed RequestBuilder::apply_flag into smaller try_apply_* helpers to lower cyclomatic complexity.
    • Consolidated duplicated tests and snapshot helpers; moved parse_helpers tests to a dedicated test module.
    • Extracted exit_status helper in the daemon handler and simplified test stdout parsing.
  • Deliberate non-applied suggestions:
    • Certain proposed consolidations (e.g., collapsing distinct parse-error types or fully generic numeric parsers) were intentionally not applied to preserve precise, user-facing error messages; these trade-offs are documented in the review traces.

Commit highlights

  • Deterministic canonical ordering and deduplication for SliceEdgeType via canonical_rank.
  • parse_uri enforces file:// URIs in request parsing.
  • Value-level parsing moved to parse_helpers with RawValue to standardise error attribution.
  • Comprehensive deterministic fixtures and Insta snapshots added to lock the contract.
  • parse_helpers tests extracted to a dedicated test module (commit: move parse_helpers tests to a separate module).

Impact

  • Establishes a stable, serde-compatible JSONL contract and deterministic test coverage to prevent schema drift and enable client discovery and early adoption. Runtime traversal behaviour and full traversal wiring are deferred to later ExecPlan stages (A–G) per the new ExecPlan document.

Walkthrough

Add a new observe graph-slice feature: define stable JSONL request/response schemas, implement CLI parsing and helpers, introduce SliceBudget and graph-slice types, wire CLI discoverability and daemon routing/handler (emits not_yet_implemented refusal), and add unit, snapshot, BDD and integration tests and fixtures.

Changes

Cohort / File(s) Summary
Documentation & Metadata
agent-skill/weaver/SKILL.md, docs/execplans/...graph-slice.md, docs/developers-guide.md, docs/users-guide.md
Remove YAML front-matter and adjust example text; add execplan and developer/user docs describing the graph-slice schema and parsing architecture.
Graph-slice Budget & Core Types
crates/weaver-cards/src/graph_slice/budget.rs, crates/weaver-cards/src/graph_slice/mod.rs
Add SliceBudget with DEFAULT_* constants, serde renames, const API, Default impl; re-export graph-slice schema types from module root.
Request Parsing & CLI Flags
crates/weaver-cards/src/graph_slice/request.rs, crates/weaver-cards/src/graph_slice/parse.rs, crates/weaver-cards/src/graph_slice/parse_helpers.rs
Implement flag enums, RequestBuilder, parsing helpers, GraphSliceRequest and parse errors; enforce defaults, validation and canonical edge-type ordering.
Response Schema & Serialization
crates/weaver-cards/src/graph_slice/response.rs
Add GraphSliceResponse (success/refusal), SliceEdge, EdgeProvenance, EdgeTarget, ResolutionScope, SliceConstraints, SliceSpillover, refusal reasons, serde annotations and convenience constructors.
Crate Export Surface
crates/weaver-cards/src/lib.rs
Expose pub mod graph_slice and re-export graph-slice public types and default limits at crate root.
Tests — Fixtures, Snapshot & Behaviour
crates/weaver-cards/src/tests/..., crates/weaver-cards/tests/features/graph_slice_schema.feature
Add deterministic fixtures, BDD steps and feature, Insta JSON snapshots, unit tests and request-parsing tests to lock down schema, defaults and validation.
Test Utilities
crates/weaver-cards/src/tests/test_utils.rs, crates/weaver-cards/src/tests/behaviour.rs
Introduce shared QuotedString test utility and remove local duplicate helper from behaviour tests.
CLI Integration & Discoverability
crates/weaver-cli/locales/en-US/messages.ftl, crates/weaver-cli/src/cli.rs, crates/weaver-cli/src/discoverability.rs
Add graph-slice to help text, localisation and the observe domain operations catalogue.
Daemon Routing & Handler
crates/weaverd/src/dispatch/observe/graph_slice.rs, crates/weaverd/src/dispatch/router.rs, crates/weaverd/src/dispatch/observe/mod.rs, tests...
Add observe graph-slice handler that parses arguments and writes a not_yet_implemented JSONL refusal; wire router and module exports; update tests and known-operations expectations.
Behaviour Tests Update
crates/weaver-cards/src/tests/behaviour.rs, crates/weaverd/src/tests/dispatch_behaviour.rs, crates/weaverd/src/dispatch/handler.rs
Replace local helpers with shared test utils and update expected known-operations lists in daemon behaviour tests.

Sequence Diagram(s)

sequenceDiagram
  rect rgba(200,220,255,0.5)
  participant CLI as "CLI / Client"
  participant Router as "Daemon Router"
  participant Handler as "graph-slice Handler"
  participant Parser as "GraphSliceRequest::parse"
  participant Writer as "ResponseWriter (stdout)"
  end

  CLI->>Router: invoke observe graph-slice + args
  Router->>Handler: route to graph-slice handler
  Handler->>Parser: parse arguments
  Parser-->>Handler: Ok(GraphSliceRequest) / Err(GraphSliceError)
  Handler->>Handler: construct GraphSliceResponse::not_yet_implemented()
  Handler->>Writer: serialize JSON and write_stdout
  Writer-->>CLI: JSONL stdout envelope
  Handler-->>Router: return DispatchResult(status)
Loading

Poem

Slice the graph with careful hands,
Budgets bound in tidy bands,
Flags parse true and defaults sing,
Emit the JSONL string,
Tests applaud the new command.

🚥 Pre-merge checks | ✅ 5 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Developer Documentation ⚠️ Warning The developers-guide.md lacks any documentation of the internal CLI request-parsing architecture, RequestBuilder pattern, Flag enum, or module responsibilities for graph_slice parsing. Add a comprehensive section to docs/developers-guide.md documenting the request-parsing architecture, including module structure, GraphSliceRequest::parse() entry point, RequestBuilder pattern, Flag enum role, and error handling mechanisms.
Module-Level Documentation ⚠️ Warning Multiple newly added modules lack module-level documentation; only mod.rs includes docstrings explaining purpose and function. Add module-level documentation (//! comments) at the top of each file before imports, clearly explaining each module's purpose, utility and function.
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The PR title directly references the roadmap item (7.2.1) and clearly describes the main deliverable (stable JSONL schemas for observe graph-slice), aligning with the comprehensive changeset.
Description check ✅ Passed The PR description comprehensively documents the changes across weaver-cards, weaverd, CLI, tests, and documentation, directly addressing the observe graph-slice surface and schema stability objectives.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Testing ✅ Passed Pull request demonstrates thorough test coverage across unit tests, snapshot tests, BDD scenarios, and integration tests guarding all new modules.
User-Facing Documentation ✅ Passed The pull request comprehensively documents the new observe graph-slice command with full syntax, all required arguments, optional parameters with defaults, response format specification with JSON examples, and implementation status note.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/7-2-1-graph-slice-execplan

Comment @coderabbitai help to get the list of available commands and usage tips.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Apr 2, 2026

Reviewer's Guide

Introduce a stable, serde-annotated JSONL contract for the observe graph-slice operation in weaver-cards, add comprehensive unit/BDD/snapshot tests and fixtures, and wire the new surface through the weaverd daemon and CLI routing while returning a structured NotYetImplemented refusal until traversal logic is implemented later.

Sequence diagram for observe graph-slice request handling

sequenceDiagram
    actor User
    participant WeaverCLI
    participant WeaverdRouter
    participant GraphSliceHandler
    participant WeaverCards as WeaverCardsSchemas

    User->>WeaverCLI: run weaver observe graph-slice --uri ... --position ...
    WeaverCLI->>WeaverdRouter: JSONL CommandRequest(operation="graph-slice", arguments)
    WeaverdRouter->>GraphSliceHandler: route to handle(request, writer)

    GraphSliceHandler->>WeaverCards: GraphSliceRequest::parse(arguments)
    alt arguments valid
        WeaverCards-->>GraphSliceHandler: GraphSliceRequest
        GraphSliceHandler->>WeaverCards: GraphSliceResponse::not_yet_implemented()
        WeaverCards-->>GraphSliceHandler: GraphSliceResponse::Refusal(NotYetImplemented)
        GraphSliceHandler->>WeaverdRouter: DispatchResult(status=1), write JSONL response
        WeaverdRouter-->>WeaverCLI: JSONL refusal payload
        WeaverCLI-->>User: print structured NotYetImplemented refusal
    else arguments invalid
        WeaverCards-->>GraphSliceHandler: GraphSliceError
        GraphSliceHandler->>WeaverdRouter: DispatchError::invalid_arguments
        WeaverdRouter-->>WeaverCLI: JSONL error response
        WeaverCLI-->>User: print invalid-arguments error
    end
Loading

Class diagram for new graph_slice schema types

classDiagram
    class SliceBudget {
        +u32 cards
        +u32 edges
        +u32 estimated_tokens
        +max_cards() u32
        +max_edges() u32
        +max_estimated_tokens() u32
    }

    class GraphSliceRequest {
        +String uri
        +u32 line
        +u32 column
        +u32 depth
        +SliceDirection direction
        +Vec~SliceEdgeType~ edge_types
        +f64 min_confidence
        +SliceBudget budget
        +DetailLevel entry_detail
        +DetailLevel node_detail
        +parse(arguments Vec~String~) GraphSliceRequest
        +uri() &str
        +line() u32
        +column() u32
        +depth() u32
        +direction() SliceDirection
        +edge_types() &Vec~SliceEdgeType~
        +min_confidence() f64
        +budget() &SliceBudget
        +entry_detail() DetailLevel
        +node_detail() DetailLevel
    }

    class SliceDirection {
        <<enum>>
        In
        Out
        Both
    }

    class SliceEdgeType {
        <<enum>>
        Call
        Import
        Config
        +all() [SliceEdgeType]
    }

    class SliceParseError {
        +String kind
        +String expected
        +String name
    }

    class GraphSliceError {
        <<enum>>
        MissingArgument
        InvalidValue
        UnknownArgument
    }

    class ResolutionScope {
        <<enum>>
        FullSymbolTable
        PartialSymbolTable
        Lsp
    }

    class EdgeProvenance {
        +String source
        +Option~EdgeProvenanceDetails~ details
    }

    class EdgeProvenanceDetails {
        +CallSiteInfo call_site
    }

    class CallSiteInfo {
        +String uri
        +u32 line
        +u32 column
    }

    class ExternalTarget {
        +String language
        +String name
    }

    class SliceEdge {
        +u32 edge_version
        +SliceEdgeType edge_type
        +String from
        +Option~String~ to
        +Option~ExternalTarget~ to_external
        +f64 confidence
        +SliceDirection direction
        +ResolutionScope resolution_scope
        +EdgeProvenance provenance
    }

    class SliceEntry {
        +String symbol_id
    }

    class SliceConstraints {
        +u32 depth
        +SliceDirection direction
        +Vec~SliceEdgeType~ edge_types
        +f64 min_confidence
        +SliceBudget budget
        +DetailLevel entry_detail
        +DetailLevel node_detail
    }

    class SpilloverCandidate {
        +String symbol_id
        +u32 depth
    }

    class SliceSpillover {
        +bool truncated
        +Vec~SpilloverCandidate~ frontier
        +empty() SliceSpillover
    }

    class SliceRefusalReason {
        <<enum>>
        NoSymbolAtPosition
        PositionOutOfRange
        UnsupportedLanguage
        NotYetImplemented
        BackendUnavailable
    }

    class SliceRefusal {
        +SliceRefusalReason reason
        +String message
    }

    class GraphSliceResponse {
        <<enum_like>>
        Success
        Refusal
        +not_yet_implemented() GraphSliceResponse
    }

    GraphSliceRequest --> SliceBudget
    GraphSliceRequest --> SliceDirection
    GraphSliceRequest --> SliceEdgeType
    GraphSliceRequest --> DetailLevel

    SliceEdge --> SliceEdgeType
    SliceEdge --> SliceDirection
    SliceEdge --> ResolutionScope
    SliceEdge --> EdgeProvenance
    SliceEdge --> ExternalTarget

    EdgeProvenance --> EdgeProvenanceDetails
    EdgeProvenanceDetails --> CallSiteInfo

    SliceConstraints --> SliceBudget
    SliceConstraints --> SliceDirection
    SliceConstraints --> SliceEdgeType
    SliceConstraints --> DetailLevel

    SliceSpillover --> SpilloverCandidate

    GraphSliceResponse --> SliceEntry
    GraphSliceResponse --> SliceConstraints
    GraphSliceResponse --> SliceEdge
    GraphSliceResponse --> SliceSpillover
    GraphSliceResponse --> SliceRefusal

    GraphSliceError --> SliceParseError
Loading

File-Level Changes

Change Details Files
Add graph-slice schema surface in weaver-cards, including request parsing, traversal budgets, response envelope, edges, spillover, and re-exports from the crate root.
  • Create graph_slice module tree with budget, request, parse, and response submodules to host the stable graph-slice contract.
  • Define SliceBudget with explicit default limits and accessors for max cards, edges, and estimated tokens.
  • Implement GraphSliceRequest with CLI-style argument parsing, defaults (depth, direction, edge_types, confidence), and accessors, backed by a RequestBuilder in parse.rs that normalizes and validates flags.
  • Define GraphSliceResponse as a success/refusal enum with SliceConstraints, SliceSpillover, SliceEdge, ResolutionScope, and refusal types, including a helper constructor for NotYetImplemented responses.
  • Update lib.rs to publicly export the new graph_slice module and its key types and defaults, expanding the crate docs from get-card-only to all observe operations.
crates/weaver-cards/src/graph_slice/mod.rs
crates/weaver-cards/src/graph_slice/budget.rs
crates/weaver-cards/src/graph_slice/parse.rs
crates/weaver-cards/src/graph_slice/request.rs
crates/weaver-cards/src/graph_slice/response.rs
crates/weaver-cards/src/lib.rs
Add tests, fixtures, and snapshots to lock the graph-slice contract semantics and JSON shapes, including BDD behaviour coverage.
  • Introduce graph_slice_fixtures with reusable builders for success, truncated, multi-resolution, refusal responses, and edge/spillover components.
  • Add graph_slice_snapshot_tests to snapshot GraphSliceRequest/Response, edges, and spillover, and verify enum snake_case serialization and budget defaults.
  • Add BDD-style graph_slice_behaviour tests plus a Gherkin feature file to cover default constraints, truncation/spillover semantics, refusal shape, edge-type normalization, and resolution_scope coverage.
  • Embed focused unit tests for GraphSliceRequest parsing (request_tests.rs) to exercise all flags, defaults, error paths, and unknown flag skipping.
  • Register the new test modules in the weaver-cards test harness and add insta snapshot files for all new snapshot tests.
crates/weaver-cards/src/tests/mod.rs
crates/weaver-cards/src/tests/graph_slice_fixtures.rs
crates/weaver-cards/src/tests/graph_slice_snapshot_tests.rs
crates/weaver-cards/src/tests/graph_slice_behaviour.rs
crates/weaver-cards/src/graph_slice/request_tests.rs
crates/weaver-cards/tests/features/graph_slice_schema.feature
crates/weaver-cards/src/tests/snapshots/weaver_cards__tests__graph_slice_snapshot_tests__*.snap
Wire the new graph-slice operation through the weaverd daemon dispatch and observe routing, returning a structured NotYetImplemented refusal for valid requests and surfacing it through tests.
  • Add observe::graph_slice module with a handle function that parses GraphSliceRequest from CommandRequest arguments and writes a GraphSliceResponse::not_yet_implemented JSON payload with status=1.
  • Extend the observe dispatch mod.rs to export the graph_slice module and update the router to route the observe/graph-slice operation to the new handler and include it in the OBSERVE domain capabilities list.
  • Add handler tests ensuring a valid request yields a refusal with reason not_yet_implemented and malformed/invalid arguments result in DispatchError via invalid_arguments.
  • Update router tests to include an invalid-arguments expectation string for observe graph-slice with no args provided.
crates/weaverd/src/dispatch/observe/mod.rs
crates/weaverd/src/dispatch/observe/graph_slice.rs
crates/weaverd/src/dispatch/observe/graph_slice_tests.rs
crates/weaverd/src/dispatch/router.rs
crates/weaverd/src/dispatch/router/tests.rs
Expose the graph-slice operation through the CLI UX and discoverability surfaces.
  • Add graph-slice to the list of observe operations in the CLI help banner output.
  • Register graph-slice in the CLI discoverability DOMAIN_OPERATIONS for the observe domain.
  • Include graph-slice in the weaverd dispatch handler tests’ advertised operation list for the observe domain.
  • Add a localized help string for observe graph-slice in the CLI messages catalog.
crates/weaver-cli/src/cli.rs
crates/weaver-cli/src/discoverability.rs
crates/weaver-cli/locales/en-US/messages.ftl
crates/weaverd/src/dispatch/handler.rs
Document the 7.2.1 execution plan for the graph-slice stable schema and tidy up non-functional agent-skill docs.
  • Add a detailed ExecPlan markdown document describing constraints, risks, plan of work, tests, and acceptance criteria for defining stable JSONL schemas for observe graph-slice.
  • Clean up the agent-skill Weaver SKILL.md by removing the front-matter block and making minor formatting tweaks to example queries.
docs/execplans/7-2-1-define-stable-jsonl-request-and-response-schemas-for-observe-graph-slice.md
agent-skill/weaver/SKILL.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

codescene-delta-analysis[bot]

This comment was marked as outdated.

- Introduce stable JSONL schema types for graph-slice requests, responses, budget constraints, edges, and refusals in weaver-cards.
- Implement parsing and normalization of graph-slice request arguments, including traversal depth, direction, edge types, and budget constraints.
- Add response types supporting success with cards, edges, spillover metadata, and structured refusals.
- Provide a dispatch handler in weaverd that parses graph-slice requests and currently returns a NotYetImplemented refusal.
- Add comprehensive behaviour-driven and snapshot tests validating schema contracts and request parsing.
- Integrate graph-slice support in CLI discoverability and router dispatch.

This initial support lays groundwork for future graph-slice traversal engine implementation.

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
@leynos leynos changed the title 7.2.1: Define stable JSONL schemas for observe graph-slice 7.2.1: Implement stable JSONL schemas for observe graph-slice Apr 7, 2026
codescene-delta-analysis[bot]

This comment was marked as outdated.

…request flags

- Introduced RequestBuilder in parse.rs to encapsulate flag parsing logic
- Moved parsing helpers into parse module for better separation of concerns
- Refactored GraphSliceRequest::parse to utilize RequestBuilder
- Added rich validation, normalization, and defaulting of flags
- Updated SliceBudget field names and ser/de annotation for clarity
- Added extensive unit tests for parsing logic
- Updated CLI and dispatch code to support new parsing logic
- Made minor stylistic improvements and test refactors

This change improves maintenance, testability, and extensibility of graph-slice request parsing.

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
codescene-delta-analysis[bot]

This comment was marked as outdated.

@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Apr 8, 2026

@coderabbitai Please suggest a fix for this issue and supply a prompt for an AI coding agent to enable it to apply the fix. Include the file and symbol names indicated in the issue at the head of your response.

crates/weaver-cards/src/graph_slice/request_tests.rs

Comment on file

fn normalizes_duplicate_edge_types() {
    let arguments = args(&[
        "--uri",
        "file:///src/main.rs",
        "--position",
        "1:1",
        "--edge-types",
        "import,call,import",
    ]);
    let request = GraphSliceRequest::parse(&arguments).expect("should parse");
    assert_eq!(
        request.edge_types(),
        &[SliceEdgeType::Call, SliceEdgeType::Import]
    );
}

❌ New issue: Code Duplication
The module contains 2 functions with similar structure: normalizes_duplicate_edge_types,normalizes_edge_types_to_canonical_order

@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Apr 8, 2026

@coderabbitai Please suggest a fix for this issue and supply a prompt for an AI coding agent to enable it to apply the fix. Include the file and symbol names indicated in the issue at the head of your response.

crates/weaverd/src/dispatch/observe/graph_slice_tests.rs

Comment on file

        if let Ok(envelope) = serde_json::from_str::<serde_json::Value>(line)
            && envelope.get("stream").and_then(|v| v.as_str()) == Some("stdout")
            && let Some(data) = envelope.get("data").and_then(|v| v.as_str())

❌ New issue: Complex Conditional
extract_stdout has 1 complex conditionals with 2 branches, threshold = 2

@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Apr 8, 2026

@coderabbitai Please suggest a fix for this issue and supply a prompt for an AI coding agent to enable it to apply the fix. Include the file and symbol names indicated in the issue at the head of your response.

crates/weaver-cards/src/graph_slice/parse.rs

Comment on file

//! Argument parsing internals for `observe graph-slice` requests.

❌ New issue: String Heavy Function Arguments
In this module, 71.4% of all arguments to its 9 functions are strings. The threshold for string arguments is 39.0%

@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Apr 8, 2026

@coderabbitai Please suggest a fix for this issue and supply a prompt for an AI coding agent to enable it to apply the fix. Include the file and symbol names indicated in the issue at the head of your response.

crates/weaver-cards/src/graph_slice/request.rs

Comment on file

    pub(super) const fn new(
        uri: String,
        line: u32,
        column: u32,
        depth: u32,
        direction: SliceDirection,
        edge_types: Vec<SliceEdgeType>,
        min_confidence: f64,
        budget: SliceBudget,
        entry_detail: DetailLevel,
        node_detail: DetailLevel,
    ) -> Self {
        Self {
            uri,
            line,
            column,
            depth,
            direction,
            edge_types,
            min_confidence,
            budget,
            entry_detail,
            node_detail,
        }
    }

❌ New issue: Excess Number of Function Arguments
GraphSliceRequest.new has 10 arguments, max arguments = 4

@coderabbitai

This comment was marked as resolved.

@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Apr 8, 2026

@coderabbitai Please suggest a fix for this issue and supply a prompt for an AI coding agent to enable it to apply the fix. Include the file and symbol names indicated in the issue at the head of your response.

crates/weaver-cards/src/graph_slice/request.rs

Comment on file

    fn from_str(s: &str) -> Result<Self, Self::Err> {
        match s {
            "in" => Ok(Self::In),
            "out" => Ok(Self::Out),
            "both" => Ok(Self::Both),
            _ => Err(DirectionParseError {
                name: String::from(s),
            }),
        }
    }

❌ New issue: Code Duplication
The module contains 2 functions with similar structure: FromStr.from_str,FromStr.from_str

@coderabbitai

This comment was marked as resolved.

@coderabbitai

This comment was marked as resolved.

@coderabbitai

This comment was marked as resolved.

@coderabbitai

This comment was marked as resolved.

leynos and others added 2 commits April 8, 2026 09:49
- Introduced a Flag enum for recognized CLI flags with Display and From implementations, improving error reporting consistency.
- Refactored parsing functions and request builder to use Flag enum instead of raw strings.
- Consolidated different parse error types into a single SliceParseError with detailed context.
- Removed redundant constructors and simplified GraphSliceRequest internals.
- Improved test coverage with parameterized tests for edge type normalization.
- Updated related handler and documentation formatting to align with code changes.

This refactor enhances code maintainability, improves error messages, and prepares the codebase for future extensions.

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
codescene-delta-analysis[bot]

This comment was marked as outdated.

@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Apr 8, 2026

@coderabbitai Please suggest a fix for this issue and supply a prompt for an AI coding agent to enable it to apply the fix. Include the file and symbol names indicated in the issue at the head of your response.

crates/weaver-cards/src/graph_slice/parse.rs

Comment on file

//! Argument parsing internals for `observe graph-slice` requests.

❌ New issue: String Heavy Function Arguments
In this module, 41.2% of all arguments to its 11 functions are strings. The threshold for string arguments is 39.0%

@coderabbitai

This comment was marked as resolved.

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
codescene-delta-analysis[bot]

This comment was marked as outdated.

Replaced raw &str arguments with RawValue struct
that bundles the flag and its string value for parsing.
This improves error reporting by providing accurate flag context
in error messages across all parse helper functions in graph_slice::parse.rs.

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
codescene-delta-analysis[bot]

This comment was marked as outdated.

…cation

Extracted a generic helper function `parse_with_fromstr` to simplify parsing logic
for types implementing `FromStr`. Updated `parse_direction` and `parse_detail` to
use this helper, reducing boilerplate and improving code clarity in parse.rs.

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
codescene-delta-analysis[bot]

This comment was marked as outdated.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

♻️ Duplicate comments (1)
docs/execplans/7-2-1-define-stable-jsonl-request-and-response-schemas-for-observe-graph-slice.md (1)

19-20: ⚠️ Potential issue | 🟡 Minor

Remove the misplaced comma in the purpose sentence.

Delete the comma after edges so the clause reads naturally and unambiguously.

✏️ Proposed fix
-describes the applied constraints, the cards and edges, that fit inside those
+describes the applied constraints, the cards and edges that fit inside those

Triage: [type:grammar] [type:docstyle]

As per coding guidelines, documentation must use en-GB-oxendict spelling and
grammar, and follow the documentation style guide for writing, formatting,
grammar, and structure standards in repository documentation.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@docs/execplans/7-2-1-define-stable-jsonl-request-and-response-schemas-for-observe-graph-slice.md`
around lines 19 - 20, Remove the misplaced comma in the sentence "describes the
applied constraints, the cards and edges, that fit inside those constraints, and
any spillover that was excluded when the traversal truncated." — edit the phrase
"the cards and edges, that fit" to "the cards and edges that fit" so the clause
reads naturally and follows en-GB-oxendict grammar and the repo documentation
style guide.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@crates/weaver-cards/src/graph_slice/parse.rs`:
- Around line 74-91: The Rustdoc for try_apply_known_flag is stale: update the
comment to state that the function returns Ok(true) if the flag was recognised
and handled (via try_apply_traversal_flag, try_apply_budget_flag, or
try_apply_detail_flag) and Ok(false) if the flag is unknown — and importantly
that it does not advance or consume the iterator when returning false (it only
returns the boolean and propagates GraphSliceError on failure). Adjust the doc
text to accurately describe this contract so callers don't assume the iterator
is skipped on unknown flags.

In
`@docs/execplans/7-2-1-define-stable-jsonl-request-and-response-schemas-for-observe-graph-slice.md`:
- Around line 422-423: Update the markdown link so the fixture-catalogue link
target matches its link text: change the hyperlink target to
../../crates/weaver-e2e/src/graph_slice_fixtures/ and use inline link syntax
[crates/weaver-e2e/src/graph_slice_fixtures/](../../crates/weaver-e2e/src/graph_slice_fixtures/)
so the displayed "module tree for graph-shaped workspaces" points to the exact
directory referenced.
- Around line 26-29: The markdown line listing default request fields contains
malformed inline code spans with leading spaces and stray backticks; fix it by
rewriting the wrapped line so each field name is a proper inline code token
(e.g., `depth`, `direction`, `edge_types`, `min_confidence`, `budget.max_cards`,
`budget.max_edges`, `budget.max_estimated_tokens`, `entry_detail`,
`node_detail`) separated by commas (or as a bulleted list) with no extra
backticks or spaces so the tokens render correctly and pass markdownlint.

---

Duplicate comments:
In
`@docs/execplans/7-2-1-define-stable-jsonl-request-and-response-schemas-for-observe-graph-slice.md`:
- Around line 19-20: Remove the misplaced comma in the sentence "describes the
applied constraints, the cards and edges, that fit inside those constraints, and
any spillover that was excluded when the traversal truncated." — edit the phrase
"the cards and edges, that fit" to "the cards and edges that fit" so the clause
reads naturally and follows en-GB-oxendict grammar and the repo documentation
style guide.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 229bd025-0ce5-48e8-b8c3-e6c00884e249

📥 Commits

Reviewing files that changed from the base of the PR and between 32ce37f and f08ddea.

📒 Files selected for processing (2)
  • crates/weaver-cards/src/graph_slice/parse.rs
  • docs/execplans/7-2-1-define-stable-jsonl-request-and-response-schemas-for-observe-graph-slice.md

Comment thread crates/weaver-cards/src/graph_slice/parse.rs Outdated
…tion

Improve readability and fix minor formatting issues in the documentation for
stable JSONL request and response schemas for observe graph-slice. Update
comments in parse.rs to better describe the behavior of try_apply_known_flag.
Fix links and format for improved clarity in execution plan docs.

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
codescene-delta-analysis[bot]

This comment was marked as outdated.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@crates/weaver-cards/src/graph_slice/parse.rs`:
- Line 18: Update the doc comment string in parse.rs that reads "Identifies a
recognised CLI flag for error-reporting purposes." to use en-GB-oxendict
spelling by replacing "recognised" with "recognized" so the comment becomes
"Identifies a recognized CLI flag for error-reporting purposes."
- Around line 73-80: Update the doc comment in impl RequestBuilder: replace the
word "recognised" with "recognized" in the summary sentence mentioning
try_apply_traversal_flag, try_apply_budget_flag, and try_apply_detail_flag so
the function comment reads "Returns `Ok(true)` if `flag` was recognized and
handled...". Ensure both occurrences in that comment (the sentence on handling
and the following sentence if repeated) are updated so the text around
RequestBuilder, try_apply_traversal_flag, try_apply_budget_flag, and
try_apply_detail_flag remains unchanged.

In
`@docs/execplans/7-2-1-define-stable-jsonl-request-and-response-schemas-for-observe-graph-slice.md`:
- Line 199: Insert a comma before "so" in the sentence "during implementation so
the design stays authoritative." to read "during implementation, so the design
stays authoritative."; locate that exact sentence in the document (the line
containing "during implementation so the design stays authoritative.") and
update the punctuation accordingly.
- Line 441: The sentence fragment "Keep snapshot names aligned with the fixture
identifiers so regressions are" is missing a comma before the coordinating
conjunction; insert a comma immediately before "so" to read "Keep snapshot names
aligned with the fixture identifiers, so regressions are" to correctly separate
the independent clauses and fix the grammar in the line shown.
- Line 164: Edit the sentence containing "reflected back into the design
document" and remove the redundant word "back" so it reads "reflected into the
design document"; update the sentence in the
docs/execplans/7-2-1-define-stable-jsonl-request-and-response-schemas-for-observe-graph-slice.md
where the phrase appears to maintain concise wording.
- Line 446: The sentence "Update the design doc first so the contract decisions
are recorded where future" is a compound sentence missing a comma before "so";
edit that sentence to insert a comma before "so" (i.e., "...first, so the
contract decisions are recorded...") to correctly separate the two independent
clauses.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 0c09f845-0aa4-4105-b770-50afbc9a2f49

📥 Commits

Reviewing files that changed from the base of the PR and between f08ddea and 1ddc956.

📒 Files selected for processing (2)
  • crates/weaver-cards/src/graph_slice/parse.rs
  • docs/execplans/7-2-1-define-stable-jsonl-request-and-response-schemas-for-observe-graph-slice.md

Comment thread crates/weaver-cards/src/graph_slice/parse.rs Outdated
Comment thread crates/weaver-cards/src/graph_slice/parse.rs
Corrected minor grammatical errors and punctuation in the design and roadmap markdown files to improve clarity and consistency.

Also fixed spelling of 'recognized' in code comments in graph_slice parse module.

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
codescene-delta-analysis[bot]

This comment was marked as outdated.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@crates/weaver-cards/src/graph_slice/parse.rs`:
- Around line 125-128: The parser currently stores any text for "--uri" via
require_arg_value and String::from(raw.value); tighten validation by adding a
parse_uri helper and using it in the "--uri" arm (replace self.uri =
Some(String::from(raw.value)) with self.uri = Some(parse_uri(raw)?)); parse_uri
should inspect raw.value, return Err(GraphSliceError::InvalidValue { flag:
raw.flag.into(), message: format!("expected a file URI, got: {value}") }) when
it doesn't start with "file://", and otherwise return the owned string;
reference require_arg_value, Flag::Uri, raw.value, parse_uri, and
GraphSliceError::InvalidValue when implementing.
- Around line 224-228: Replace the unstable reliance on Ord-based sorting for
edge_types: instead of calling edge_types.sort() in parse.rs, sort with a
canonical schema rank (e.g.,
edge_types.sort_by_key(SliceEdgeType::canonical_rank)) and keep
edge_types.dedup(); add a const fn canonical_rank(self) -> u8 on the
SliceEdgeType enum that returns explicit ranks (e.g., Call = 0, Import = 1,
Config = 2) so wire-order is deterministic regardless of enum declaration order.

In
`@docs/execplans/7-2-1-define-stable-jsonl-request-and-response-schemas-for-observe-graph-slice.md`:
- Line 8: The exec plan file still shows "Status: DRAFT" and unchecked
stage/approval items despite the PR already adding schemas, routing, tests and
docs; update the document to reflect the current implementation by changing
Status to the appropriate value (e.g., APPROVED or IMPLEMENTED), check off
Stages A–F in the stage checklist, and update the approval gate text to indicate
implementation has occurred and who approved; apply the same updates in the
other referenced ranges (lines ~120-139 and ~485-489) so the plan, stage
checklist, and approval statements accurately match the code changes introduced
in this PR.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 693f39ec-a086-4b95-95c6-fd27b33057ed

📥 Commits

Reviewing files that changed from the base of the PR and between 1ddc956 and f72350c.

📒 Files selected for processing (2)
  • crates/weaver-cards/src/graph_slice/parse.rs
  • docs/execplans/7-2-1-define-stable-jsonl-request-and-response-schemas-for-observe-graph-slice.md

Comment thread crates/weaver-cards/src/graph_slice/parse.rs
Comment thread crates/weaver-cards/src/graph_slice/parse.rs
…ate file URI

- Introduce `canonical_rank` for SliceEdgeType to ensure deterministic sorting
- Sort and deduplicate edge types using the canonical rank
- Add `parse_uri` function to validate that URIs start with 'file://'
- Update ExecPlan status to IN_PROGRESS and mark several stages as completed

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
@leynos leynos changed the title 7.2.1: Stable JSONL schemas for observe graph-slice 7.2.1: Stable JSONL request/response schemas for observe graph-slice Apr 11, 2026
codescene-delta-analysis[bot]

This comment was marked as outdated.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@crates/weaver-cards/src/graph_slice/parse.rs`:
- Around line 1-402: Split out the value-level parsing helpers into a new
sibling submodule and keep RequestBuilder orchestration in parse.rs: move
RawValue, require_arg_value, and all parse_* helpers (parse_uri, parse_position,
parse_u32, parse_direction, parse_edge_types, parse_confidence,
parse_with_fromstr, parse_detail) into the new submodule file, make their
visibility compatible with RequestBuilder (pub(super) or crate-level as needed),
add a mod declaration and import those symbols into parse.rs, and update any
references in RequestBuilder (e.g., try_apply_traversal_flag,
try_apply_budget_flag, try_apply_detail_flag, build) to use the moved functions;
ensure the new module re-exports or exposes the helpers so the existing tests
and callers still compile.

In
`@docs/execplans/7-2-1-define-stable-jsonl-request-and-response-schemas-for-observe-graph-slice.md`:
- Around line 31-33: The docs mention the resolution_scope enum value `lsp`
which is inconsistent with the implemented schema; update all occurrences of the
documented enum for resolution_scope (the list containing `full_symbol_table`,
`partial_symbol_table`, `lsp`) to use `unresolved` instead of `lsp` so the docs
match the response contract (`full_symbol_table`, `partial_symbol_table`,
`unresolved`), e.g., update the enum examples and any explanatory text
referencing `lsp`.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 6329bb9d-5704-42a7-a937-3c396f20642d

📥 Commits

Reviewing files that changed from the base of the PR and between f72350c and 2a3b3ea.

📒 Files selected for processing (3)
  • crates/weaver-cards/src/graph_slice/parse.rs
  • crates/weaver-cards/src/graph_slice/request.rs
  • docs/execplans/7-2-1-define-stable-jsonl-request-and-response-schemas-for-observe-graph-slice.md

Comment thread crates/weaver-cards/src/graph_slice/parse.rs Outdated
…_helpers module

Moved all value-level command-line argument parsing helper functions and the RawValue struct
from parse.rs to a new parse_helpers.rs module. This improves modularity by separating
low-level parsing logic from higher-level request building, clarifies code organization,
and maintains existing functionality with more focused responsibility in each module.
Updated parse.rs to import the helpers from the new module and added parse_helpers mod declaration.

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
@leynos leynos changed the title 7.2.1: Stable JSONL request/response schemas for observe graph-slice 7.2.1: Stable JSONL schemas for observe graph-slice Apr 11, 2026
codescene-delta-analysis[bot]

This comment was marked as outdated.

… helpers

- Introduced extensive unit tests for functions in parse_helpers.rs
- Covered argument value requirement, URI parsing, position parsing,
  unsigned integer parsing, direction, edge types, confidence levels, and detail level parsing
- Improved validation coverage ensuring robust error handling on invalid inputs
- Tests make use of rstest for parameterized cases
- Overall increase in test coverage and stability of graph-slice request parsing

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
codescene-delta-analysis[bot]

This comment was marked as outdated.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@crates/weaver-cards/src/graph_slice/parse_helpers.rs`:
- Around line 1-443: Extract the entire #[cfg(test)] mod tests { ... } block
(which contains tests like require_arg_value_returns_value,
parse_uri_accepts_file_uri, parse_position_accepts_valid_pair,
parse_confidence_accepts_valid_range, parse_detail_accepts_valid_levels, etc.)
out of parse_helpers.rs and place it in its own test source file as a standalone
module so parse_helpers.rs falls under the 400-line limit; in the new test file
keep the same use imports (use rstest::rstest; use super::*;) or change to use
crate::graph_slice::parse_helpers::* as appropriate, ensure the test module
still compiles by adjusting visibility/imports for RawValue, require_arg_value,
parse_uri, parse_position, parse_u32, parse_direction, parse_edge_types,
parse_confidence, and parse_detail, and remove the original #[cfg(test)] block
from parse_helpers.rs.
- Around line 258-262: The failing CI is due to formatting drift in the test
file around the test function parse_position_rejects_zero_line and two other
nearby test blocks; run the project formatter and commit the result: run make
check-fmt (or cargo fmt / rustfmt) on the file that contains
parse_position_rejects_zero_line, correct formatting for the three hunks (the
test containing parse_position_rejects_zero_line and the two subsequent test
blocks), then re-run make lint and make test and commit the formatted changes so
CI passes.
- Around line 191-443: Tests call functions like require_arg_value, parse_uri,
parse_position, parse_u32, parse_direction, parse_edge_types, parse_confidence,
and parse_detail using .unwrap() and .unwrap_err(); replace each .unwrap() with
.expect("meaningful message describing the expected success, e.g. expected value
for --uri or expected valid parse of POSITION") and each .unwrap_err() with
.expect_err("meaningful message describing the expected failure, e.g. expected
error for invalid POSITION or unknown --edge-types"), updating messages to
reference the Flag/RawValue under test (e.g. Flag::Uri, Flag::Position,
Flag::EdgeTypes) so failures show clear context; do this for all occurrences in
the test module (including tests for RawValue::new and the various Flag cases).

In `@docs/developers-guide.md`:
- Around line 339-342: Update the first occurrence of "URI" in this section to
read "Uniform Resource Identifier (URI)" and then use "URI" for subsequent
mentions; specifically change the description for parse_uri to refer to a
"Uniform Resource Identifier (URI) prefix" on first use and keep later
references (including in parse_uri, require_arg_value, and parse_position
descriptions) as "URI". Ensure the phrase appears exactly once expanded and all
other instances use the abbreviation.

In `@docs/users-guide.md`:
- Around line 835-837: The sentence describing resolution_scope uses
non-parallel phrasing; rewrite it to a parallel form (e.g., using "either ... or
...") and use British English spelling/grammar; specifically, update the
sentence that mentions the values `full_symbol_table`, `partial_symbol_table`,
and `lsp` so it reads like "Each edge carries a `resolution_scope` that is
either `full_symbol_table`, `partial_symbol_table` or `lsp`, indicating how the
target was resolved." Ensure punctuation and conjunctions follow en-GB
standards.
- Around line 804-823: The example JSON uses "to" but the code exposes the
flattened target shape via SliceEdge (see SliceEdge and its #[serde(flatten)]
target in response.rs), so change the example to replace the "to" field with the
flattened "target" object structure used by SliceEdge (inline the target's
fields at the same level as other edge props), ensuring the example matches the
shape produced by the target flattening and includes the same keys/structure as
defined on SliceEdge's target type.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 22137196-8b35-4854-b8dd-aad1a0315855

📥 Commits

Reviewing files that changed from the base of the PR and between 1137d3c and f56b97a.

📒 Files selected for processing (3)
  • crates/weaver-cards/src/graph_slice/parse_helpers.rs
  • docs/developers-guide.md
  • docs/users-guide.md

Comment thread crates/weaver-cards/src/graph_slice/parse_helpers.rs Outdated
Comment thread crates/weaver-cards/src/graph_slice/parse_helpers.rs Outdated
Comment thread crates/weaver-cards/src/graph_slice/parse_helpers.rs Outdated
Comment thread docs/developers-guide.md
Comment thread docs/users-guide.md
Comment thread docs/users-guide.md Outdated
…stency

- Introduced helper function `assert_err_contains` to simplify error assertion checks.
- Replaced direct `unwrap`, `unwrap_err`, and manual error message inspections with helper for more concise tests.
- Changed Vec to array literals for argument lists to reduce heap allocations.
- Improved formatting and assertion descriptions for better test failure messages.
- Overall cleanup enhances readability and maintainability of parsing tests.

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
codescene-delta-analysis[bot]

This comment was marked as outdated.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
crates/weaver-cards/src/graph_slice/parse_helpers.rs (1)

181-434: ⚠️ Potential issue | 🟠 Major

Split the in-file test module now to satisfy the hard 400-line cap.

Move #[cfg(test)] mod tests into a separate test file and keep parse_helpers.rs focused on production parsing helpers.

As per coding guidelines: "Files must not exceed 400 lines in length".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/weaver-cards/src/graph_slice/parse_helpers.rs` around lines 181 - 434,
Extract the entire #[cfg(test)] mod tests { ... } block out of parse_helpers.rs
into a new test file (e.g., src/graph_slice/parse_helpers_tests.rs) so
parse_helpers.rs stays under the 400-line limit; in the new file replace use
super::*; with use crate::graph_slice::parse_helpers::*; and keep the rstest
import (use rstest::rstest;) at top, ensure any helper functions (like
assert_err_contains) remain in the new test file, and remove the original
#[cfg(test)] mod tests block from parse_helpers.rs.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@crates/weaver-cards/src/graph_slice/parse_helpers.rs`:
- Around line 181-434: Extract the entire #[cfg(test)] mod tests { ... } block
out of parse_helpers.rs into a new test file (e.g.,
src/graph_slice/parse_helpers_tests.rs) so parse_helpers.rs stays under the
400-line limit; in the new file replace use super::*; with use
crate::graph_slice::parse_helpers::*; and keep the rstest import (use
rstest::rstest;) at top, ensure any helper functions (like assert_err_contains)
remain in the new test file, and remove the original #[cfg(test)] mod tests
block from parse_helpers.rs.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 8fabeabb-8092-41b4-aace-031b20d49c4c

📥 Commits

Reviewing files that changed from the base of the PR and between f56b97a and 260225c.

📒 Files selected for processing (1)
  • crates/weaver-cards/src/graph_slice/parse_helpers.rs

Remove inline tests from parse_helpers.rs and move them to a new
parse_helpers_tests.rs file. This cleans up the main source file and
organizes tests into a dedicated test module. Also update mod.rs to
conditionally include the new test modules.

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (3)
docs/execplans/7-2-1-define-stable-jsonl-request-and-response-schemas-for-observe-graph-slice.md (2)

26-29: ⚠️ Potential issue | 🟡 Minor

Fix broken inline code tokens in the defaults list.

Rewrite this wrapped sentence so every field name is a valid inline code span without stray leading spaces or detached backticks.

✏️ Proposed fix
-1. `weaver observe graph-slice --uri <Uniform Resource Identifier (URI)>
-   --position
-   <LINE:COL>` parses into a typed request with explicit default values for `
-   depth`, `direction`, `edge_types`, `min_confidence`, `budget.max_cards`, `
-   budget.max_edges`, `budget.max_estimated_tokens`, `entry_detail`, and `
-   node_detail`.
+1. `weaver observe graph-slice --uri <Uniform Resource Identifier (URI)>
+   --position <LINE:COL>` parses into a typed request with explicit default
+   values for `depth`, `direction`, `edge_types`, `min_confidence`,
+   `budget.max_cards`, `budget.max_edges`, `budget.max_estimated_tokens`,
+   `entry_detail`, and `node_detail`.

Triage: [type:syntax/md] [type:docstyle]
As per coding guidelines, follow markdownlint-style Markdown syntax and keep inline code spans well-formed in documentation.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@docs/execplans/7-2-1-define-stable-jsonl-request-and-response-schemas-for-observe-graph-slice.md`
around lines 26 - 29, The sentence listing default request fields has broken
inline code spans; rewrite it so each field name is wrapped as a proper inline
code span (no leading spaces or stray backticks) — specifically ensure `depth`,
`direction`, `edge_types`, `min_confidence`, `budget.max_cards`,
`budget.max_edges`, `budget.max_estimated_tokens`, `entry_detail`, and
`node_detail` appear as well-formed inline code tokens and the sentence flows
naturally without detached backticks or extra spaces.

148-152: ⚠️ Potential issue | 🟠 Major

Update stale discovery notes to match completed implementation.

Replace this claim that no observe graph-slice implementation exists. It now conflicts with Line 130-Line 140 and Line 492-Line 496, which state Stages A-D are complete and routing is already wired.

✏️ Proposed fix
-- There is no `observe graph-slice` implementation yet anywhere in the
-  codebase. The current observe router in
-  [crates/weaverd/src/dispatch/router.rs](../../crates/weaverd/src/dispatch/router.rs)
-   only recognizes `get-definition`, `find-references`, `grep`, `diagnostics`,
-  `call-hierarchy`, and `get-card`.
+- `observe graph-slice` is now wired into the router and dispatch path.
+  Remaining work sits in end-to-end fixture breadth and final documentation
+  synchronization before the roadmap item is fully closed.

Triage: [type:docstyle]
As per coding guidelines, ensure documentation reflects current API and behavioural state in docs/.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@docs/execplans/7-2-1-define-stable-jsonl-request-and-response-schemas-for-observe-graph-slice.md`
around lines 148 - 152, The doc contains a stale assertion that "There is no
`observe graph-slice` implementation"; remove or replace that sentence in
docs/execplans/7-2-1-define-stable-jsonl-request-and-response-schemas-for-observe-graph-slice.md
and update the discovery notes to state that `observe graph-slice` is
implemented and routing is wired in the observe router (referencing the router
in crates/weaverd/src/dispatch/router.rs) and that Stages A–D are complete;
ensure the new text aligns with the existing statements about Stages A–D and the
routing references elsewhere in the document.
docs/users-guide.md (1)

803-808: ⚠️ Potential issue | 🟠 Major

Align the edge example with the actual graph-slice response schema.

Replace the to field with the flattened target shape emitted by SliceEdge; this example currently documents a payload shape that does not match the stable contract.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/users-guide.md` around lines 803 - 808, The example edge JSON in
docs/users-guide.md uses a "to" field that doesn't match the actual graph-slice
response; update the sample to replace the "to" key with the flattened target
shape produced by SliceEdge (i.e., use the exact flattened target properties
emitted by the SliceEdge implementation rather than a single "to" id), ensuring
fields and nesting mirror the SliceEdge output schema so the documented payload
matches the stable contract.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In
`@docs/execplans/7-2-1-define-stable-jsonl-request-and-response-schemas-for-observe-graph-slice.md`:
- Around line 26-29: The sentence listing default request fields has broken
inline code spans; rewrite it so each field name is wrapped as a proper inline
code span (no leading spaces or stray backticks) — specifically ensure `depth`,
`direction`, `edge_types`, `min_confidence`, `budget.max_cards`,
`budget.max_edges`, `budget.max_estimated_tokens`, `entry_detail`, and
`node_detail` appear as well-formed inline code tokens and the sentence flows
naturally without detached backticks or extra spaces.
- Around line 148-152: The doc contains a stale assertion that "There is no
`observe graph-slice` implementation"; remove or replace that sentence in
docs/execplans/7-2-1-define-stable-jsonl-request-and-response-schemas-for-observe-graph-slice.md
and update the discovery notes to state that `observe graph-slice` is
implemented and routing is wired in the observe router (referencing the router
in crates/weaverd/src/dispatch/router.rs) and that Stages A–D are complete;
ensure the new text aligns with the existing statements about Stages A–D and the
routing references elsewhere in the document.

In `@docs/users-guide.md`:
- Around line 803-808: The example edge JSON in docs/users-guide.md uses a "to"
field that doesn't match the actual graph-slice response; update the sample to
replace the "to" key with the flattened target shape produced by SliceEdge
(i.e., use the exact flattened target properties emitted by the SliceEdge
implementation rather than a single "to" id), ensuring fields and nesting mirror
the SliceEdge output schema so the documented payload matches the stable
contract.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 7ad95162-b5ea-443c-b50c-1248f38d7b73

📥 Commits

Reviewing files that changed from the base of the PR and between 260225c and be9351f.

📒 Files selected for processing (8)
  • crates/weaver-cards/src/graph_slice/mod.rs
  • crates/weaver-cards/src/graph_slice/parse_helpers.rs
  • crates/weaver-cards/src/graph_slice/parse_helpers_tests.rs
  • crates/weaver-cards/src/graph_slice/request.rs
  • crates/weaver-cards/src/graph_slice/request_tests.rs
  • docs/developers-guide.md
  • docs/execplans/7-2-1-define-stable-jsonl-request-and-response-schemas-for-observe-graph-slice.md
  • docs/users-guide.md

@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Apr 12, 2026

@coderabbitai Have the following now been resolved?

If further work is required, please provide an AI agent prompt for the remaining work to be done to address this comment.

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Developer Documentation ⚠️ Warning The developers-guide.md lacks any documentation of the internal CLI request-parsing architecture, RequestBuilder pattern, Flag enum, or module responsibilities for graph_slice parsing. Add a comprehensive section to docs/developers-guide.md documenting the request-parsing architecture, including module structure, GraphSliceRequest::parse() entry point, RequestBuilder pattern, Flag enum role, and error handling mechanisms.
Module-Level Documentation ⚠️ Warning Multiple newly added modules lack module-level documentation; only mod.rs includes docstrings explaining purpose and function. Add module-level documentation (//! comments) at the top of each file before imports, clearly explaining each module's purpose, utility and function.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 12, 2026

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
echo "=== docs/developers-guide.md (graph_slice section) ==="
grep -n "graph.slice\|graph_slice\|RequestBuilder\|Flag enum\|parse_helpers\|parse\.rs\|request\.rs" docs/developers-guide.md | head -60

echo ""
echo "=== Module-level docs in graph_slice files ==="
for f in crates/weaver-cards/src/graph_slice/budget.rs \
          crates/weaver-cards/src/graph_slice/parse.rs \
          crates/weaver-cards/src/graph_slice/parse_helpers.rs \
          crates/weaver-cards/src/graph_slice/request.rs \
          crates/weaver-cards/src/graph_slice/response.rs \
          crates/weaver-cards/src/graph_slice/mod.rs; do
  echo "--- $f ---"
  head -10 "$f"
  echo ""
done

echo "=== weaverd graph_slice.rs module doc ==="
head -10 crates/weaverd/src/dispatch/observe/graph_slice.rs

echo "=== weaverd graph_slice_tests.rs module doc ==="
head -10 crates/weaverd/src/dispatch/observe/graph_slice_tests.rs

echo "=== test files module docs ==="
for f in crates/weaver-cards/src/tests/graph_slice_behaviour.rs \
          crates/weaver-cards/src/tests/graph_slice_fixtures.rs \
          crates/weaver-cards/src/tests/graph_slice_snapshot_tests.rs \
          crates/weaver-cards/src/tests/test_utils.rs; do
  echo "--- $f ---"
  head -10 "$f"
  echo ""
done

Length of output: 5874


@leynos — both warnings are resolved.

Developer Documentation ✅
docs/developers-guide.md already contains a dedicated section (from line 293 onwards) covering the observe graph-slice parsing pipeline, the RequestBuilder accumulator pattern, the Flag enum's role and visibility, the parse_helpers module, RawValue, and GraphSliceError handling. All elements called out in the warning are present.

Module-Level Documentation ✅
Every newly added module carries //! documentation:

File Status
graph_slice/budget.rs ✅ Multi-line //!
graph_slice/parse.rs ✅ Multi-line //!
graph_slice/parse_helpers.rs ✅ Multi-line //!
graph_slice/request.rs ✅ Multi-line //!
graph_slice/response.rs ✅ Multi-line //!
graph_slice/mod.rs ✅ Multi-line //!
weaverd/…/graph_slice.rs ✅ Multi-line //!
weaverd/…/graph_slice_tests.rs ✅ Single-line //!
tests/graph_slice_behaviour.rs ✅ Single-line //!
tests/graph_slice_fixtures.rs ✅ Multi-line //!
tests/graph_slice_snapshot_tests.rs ✅ Multi-line //!
tests/test_utils.rs ✅ Single-line //!

No further work is required for either warning.

@leynos leynos merged commit 13215a5 into main Apr 12, 2026
11 checks passed
@leynos leynos deleted the codex/7-2-1-graph-slice-execplan branch April 12, 2026 20:04
@coderabbitai coderabbitai Bot mentioned this pull request Apr 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant