Skip to content

Add packages/daemon: protobuf schema and tonic/prost build pipeline - #1126

Merged
malibio merged 3 commits into
mainfrom
feature/issue-1111-daemon-proto-pipeline
May 17, 2026
Merged

malibio merged 3 commits into
mainfrom
feature/issue-1111-daemon-proto-pipeline

Conversation

@malibio

@malibio malibio commented May 17, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Adds packages/daemon/ crate to the Cargo workspace as the gRPC foundation for ADR-031 (daemon-client architecture)
  • Defines NodeService proto with 8 RPCs (CreateNode, GetNode, UpdateNode, DeleteNode, GetChildren, SearchNodes, WatchNodes server-stream, Chat bidirectional stream) — message shapes aligned with packages/core/src/ops/
  • Defines AgentSessionService proto with 6 RPCs for PTY/terminal-style agent sessions
  • build.rs uses tonic-build + protoc-bin-vendored — no system protoc required

Verification

  • cargo build -p nodespace-daemon — passes
  • cargo test -p nodespace-daemon — passes (0 tests, proto compilation is the real test)
  • cargo clippy -p nodespace-daemon -- -D warnings — clean
  • cargo clippy --all-targets -- -D warnings -D clippy::unused-async — clean workspace-wide
  • cargo fmt --all — clean (one trailing newline removed from schema.rs)
  • Rust core tests: 1182 passed, 0 failed

Test plan

  • cargo build -p nodespace-daemon compiles cleanly
  • cargo test -p nodespace-daemon passes
  • cargo clippy -p nodespace-daemon -- -D warnings is clean
  • Proto message field shapes reviewed against packages/core/src/ops/node_ops.rs

Deviations from issue spec

None. Implemented exactly per spec. Message design notes:

  • version = 0 in CreateNode/UpdateNode/DeleteNode means "auto-fetch current" (matches ops-layer behaviour where None triggers auto-fetch)
  • properties field is a JSON-encoded string (matches the Value JSON serialisation in ops layer)
  • WatchNodes uses oneof NodeEvent { NodeData created, NodeData updated, NodeDeleted deleted } — sufficient for initial watch subscription support
  • Chat uses {content, session_id} request and {content, done, session_id} response — minimal and consistent

Closes #1111

🤖 Generated with Claude Code

…loses #1111)

Establishes the gRPC foundation for ADR-031 (daemon-client architecture).
No server handlers — just the crate skeleton, proto definitions, build.rs,
and re-exported generated types.

New files:
- packages/daemon/Cargo.toml — crate manifest with tonic 0.12 + prost 0.13
- packages/daemon/build.rs — tonic-build + protoc-bin-vendored (no system protoc)
- packages/daemon/proto/node_service.proto — NodeService: CreateNode, GetNode,
  UpdateNode, DeleteNode, GetChildren, SearchNodes, WatchNodes (server stream),
  Chat (bidirectional stream); message shapes aligned with packages/core/src/ops/
- packages/daemon/proto/agent_session_service.proto — AgentSessionService:
  LaunchSession, StreamOutput, WriteInput, ResizeTerminal, TerminateSession,
  ListSessions; PTY/terminal field shapes
- packages/daemon/src/lib.rs — re-exports generated nodespace module

Updated:
- Cargo.toml (workspace root) — add packages/daemon member
- packages/core/src/mcp/handlers/schema.rs — cargo fmt trailing newline removal

Proto message field shapes:
- node_id: string UUID
- node_type: string (e.g. "text", "task", "date")
- content: string
- properties: JSON-encoded string (matches ops layer Value serialisation)
- version: int64 (OCC counter; 0 = auto-fetch, matching ops-layer behaviour)
- lifecycle_status: string enum ("active" | "archived" | "deleted")

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@malibio

malibio commented May 17, 2026

Copy link
Copy Markdown
Collaborator Author

Code Review Summary

Review Type: Initial Review

This PR sets up the packages/daemon/ crate skeleton with proto schemas and a tonic/prost build pipeline. The crate compiles, clippy is clean workspace-wide, and the proto schemas are well-organized and thoughtfully aligned with the ops layer in most respects.

However, there is a critical build-pipeline bug that silently drops the entire NodeService API from the compiled output. The build succeeds only because no consumer references the missing types yet — this would block every downstream issue. Details below.


Requirements Check

Acceptance Criterion Status Notes
packages/daemon/ crate exists and is added to Cargo workspace ✅ Added to Cargo.toml workspace members
proto/node_service.proto defines NodeService with all listed methods ✅ (source) / ❌ (compiled) All 8 RPCs present in .proto, but NodeService types are missing from generated Rust (see Blocker #1)
proto/agent_session_service.proto defines AgentSessionService with all listed methods ✅ All 6 RPCs present and compile
build.rs uses tonic-build + protoc-bin-vendored — no system protoc required ⚠️ Uses both crates correctly, but the two compile_protos calls collide (Blocker #1)
Generated Rust types compile (cargo build -p daemon) ❌ cargo build -p daemon fails with package ID specification 'daemon' did not match any packages. Crate is named nodespace-daemon. See Improvement #1
No system protoc required ✅ protoc-bin-vendored confirmed working
cargo test -p daemon passes ❌ (literally) / ✅ (under -p nodespace-daemon) 0 tests, passes
Code passes bun run quality:fix ✅ Rust clippy -D warnings clean across workspace

Findings

Critical Issues

[Blocker] packages/daemon/build.rs:4-5 — NodeService types are completely missing from the generated crate

The build.rs invokes tonic_build::compile_protos() twice — once per proto file. Each call writes a fresh nodespace.rs into $OUT_DIR, so the second call (for agent_session_service.proto) overwrites the first. After a clean build:

$ grep -c "NodeService"      target/debug/build/nodespace-daemon-*/out/nodespace.rs
0
$ grep -c "AgentSessionService" target/debug/build/nodespace-daemon-*/out/nodespace.rs
52

No NodeData, no CreateNodeRequest, no NodeService client/server traits exist in the compiled crate. The build passes only because lib.rs just does tonic::include_proto!("nodespace") without referencing any specific type — every server/client/Tauri consumer that lands in the next issue will fail to compile.

This is the central deliverable of the PR (the issue is literally titled "Define protobuf schema… for nodespaced") and it's silently broken. The fact that the verification block in the PR description shows green is because cargo build -p nodespace-daemon doesn't transitively need NodeService types yet.

Fix: Call compile_protos once with both files. Using tonic_build::configure() gives you a compile_protos(files, includes) signature that handles multiple files in one pass:

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let protoc = protoc_bin_vendored::protoc_bin_path()?;
    std::env::set_var("PROTOC", protoc);
    tonic_build::configure().compile_protos(
        &["proto/node_service.proto", "proto/agent_session_service.proto"],
        &["proto"],
    )?;
    Ok(())
}

Also: please add a smoke test in lib.rs that references at least one type from each service (e.g. a const _: fn() = || { let _: Option<nodespace::NodeData> = None; let _: Option<nodespace::SessionInfo> = None; };) so this class of bug is caught at cargo build rather than discovered in the next PR. Without that guard the regression is invisible.

Engineering principle: fail fast. A build artifact whose contents don't match the source is worse than a build failure — it propagates the silent gap to every consumer.


Suggested Improvements

[Improvement] Issue acceptance criterion cargo build -p daemon is literally unsatisfied — crate is nodespace-daemon

Running cargo build -p daemon produces error: package ID specification 'daemon' did not match any packages. The crate is named nodespace-daemon, which is correct and consistent with every other workspace crate (nodespace-core, nodespace-agent, nodespace-nlp-engine, nodespace-dev-tools). The issue spec uses the bare name daemon colloquially.

Two options, both fine:

  1. Note in the PR description that the crate uses the nodespace- prefix for workspace consistency and -p nodespace-daemon is the correct invocation. (Recommended — the prefix is the established convention.)
  2. Drop the prefix to match the spec literally.

I recommend (1). The acceptance criterion is satisfied in spirit; please just call it out so the reviewer of the next issue doesn't trip on it.

[Improvement] proto/node_service.proto:125-136 — SearchRequest doesn't fully align with the ops layer

The proto's SearchRequest is a hybrid of QueryNodesInput (structured query) and SearchSemanticInput (semantic search), gated by a semantic boolean. Compared to packages/core/src/ops/search_ops.rs::SearchSemanticInput, it's missing:

  • node_types: Vec<String> — the ops layer accepts an array of types; the proto exposes a single node_type string. This will lose information the moment a UI client wants to search across [task, text].
  • exclude_collections: Vec<String>
  • include_markdown: i32, include_archived: bool, scope: string
  • include_edges: bool, graph_boost: bool
  • property_filters (JSON object)

I'm not asking you to expand the schema right now — most of these are advanced features and YAGNI applies until the gRPC client surface actually needs them. But I'd suggest one of:

  1. Document the scope limitation in a proto comment above SearchRequest ("Initial schema — exclude_collections, include_markdown, include_archived, scope, include_edges, graph_boost, property_filters, and multi-type filtering will be added in #"), so the next issue knows the gap exists.
  2. Convert node_type to repeated string node_types now. This is the one field that will require a breaking proto change later (singular → plural / single value → repeated) if not fixed up front. Cheap to do now, painful to do later — that's exactly the case where adding it up front is correct.

Engineering principle: minimize breaking proto changes. Adding new fields is free; changing field types/cardinalities is breaking. The node_types repeated form is a known requirement from SearchSemanticInput — lock it in now.

[Improvement] proto/node_service.proto:78-88 — UpdateNodeRequest uses empty-string-as-sentinel which conflicts with legitimate empty values

The proto comments // empty string = no change for node_type, content, properties, and lifecycle_status. This works for node_type and lifecycle_status (which can't legitimately be empty), but content can legitimately be empty — clearing a text node's content to "" is a normal operation, and the ops layer's Option<String> correctly distinguishes "no change" from "set to empty". The proto schema loses that distinction.

Two clean options in proto3:

  1. Wrap the optional fields in optional (proto3 supports field presence via optional keyword): optional string content = 4; — prost generates Option<String> for these.
  2. Use a separate boolean flag (clear_content) or a oneof — heavier-weight.

Option (1) is the idiomatic fix and matches the Option<String> shape of UpdateNodeInput exactly. Same applies to properties (clearing properties to {} is meaningful).

Engineering principle: don't overload sentinel values. Distinct semantics deserve distinct representations.

[Improvement] proto/node_service.proto:30-41 — NodeData.properties as JSON string is reasonable but should be documented as deliberate

You've chosen string properties (JSON-encoded) rather than google.protobuf.Struct or google.protobuf.Any. This is a defensible choice — it avoids a protobuf-well-known-types dependency, matches the serde_json::Value shape in the ops layer, and lets schema validation happen server-side rather than wire-side. But it has costs:

  • Clients must parse JSON on every read/write
  • The wire format doesn't self-describe — generated code gives you String, not a structured type
  • google.protobuf.Struct exists exactly for this case and is supported by every gRPC language

I'm fine with the current choice (KISS, matches ops layer), but please add a comment in the proto explaining the trade-off so the next contributor doesn't "improve" it without understanding the rationale.

[Improvement] proto/node_service.proto:80,98 — version = 0 sentinel for "auto-fetch" is acceptable but fragile

version = 0 means auto-fetch current version (matches ops-layer behaviour). The ops layer uses Option<i64> which is unambiguous; proto3 i64 defaults to 0 on missing field, so the sentinel works. But version 0 is a valid version number (newly-created nodes start at 0 in many systems — please double-check the actual initial version in NodeService::create_node_with_parent). If a node is ever legitimately at version 0, this collides.

Two options:

  1. Switch to optional int64 version = 2; (proto3 optional → Option<i64> in prost) — matches the ops-layer exactly.
  2. Document explicitly that versions start at 1 in this system, with a code comment in the Rust layer asserting it.

I recommend (1) — same reasoning as the UpdateNodeRequest optional fields. It's literally the proto3 idiom for this case.


Nitpicks

  • Nit: packages/daemon/src/lib.rs:17 — #![allow(clippy::all)] on the generated module is the correct pattern for prost output (per CLAUDE.md, the no-suppression rule applies to hand-written code, not generated). Scope is properly limited to the module via the inner attribute. No action needed; flagging for the reviewer record.

  • Nit: proto/node_service.proto:34 — comment says "empty string when no parent (root node)". Consider optional string parent_id = 4; here too for consistency with the recommendation above. Same trade-off applies.

  • Nit: proto/agent_session_service.proto:142 — int32 exit_code = 6; // meaningful only when status = SESSION_STATUS_EXITED. Consider optional int32 exit_code = 6; so consumers can distinguish "running, no exit code yet" from "exited with code 0" without checking a sibling field. Same defensible choice as elsewhere.

  • Nit: proto/node_service.proto:172-176 — ChatResponse.session_id echoed back is fine, but consider whether done should be a oneof with a richer terminal payload (final tool calls, token usage, etc.). YAGNI applies for this PR — just flagging that this RPC will likely evolve fastest as the agent layer matures.

  • Nit: packages/core/src/mcp/handlers/schema.rs:1020 — Single-line whitespace fix is unrelated to this PR's main purpose. Harmless, but per CLAUDE.md "the change is atomic (single, cohesive purpose) not bundling unrelated changes" — strictly speaking this belongs in its own commit. Not worth re-opening for.

  • Nit: packages/daemon/build.rs:2 — .unwrap() on protoc_bin_path(). Once you fix the multi-file compile issue, propagating the error with ? (it already returns Result) is slightly cleaner. The function signature returns Result, so let protoc = protoc_bin_vendored::protoc_bin_path()?; works.


Verification Performed

cargo build -p daemon            → FAILS (package not found; crate is nodespace-daemon)
cargo build -p nodespace-daemon  → PASSES
cargo test  -p nodespace-daemon  → PASSES (0 tests)
cargo clippy -p nodespace-daemon -- -D warnings → CLEAN
cargo clippy --workspace --all-targets -- -D warnings → CLEAN

grep "NodeService"      generated/nodespace.rs → 0 hits  ← BLOCKER
grep "AgentSessionService" generated/nodespace.rs → 52 hits

The generated proto code contains only AgentSessionService — NodeService was overwritten.


Recommendation

Request Changes. The build pipeline bug is a hard blocker — the PR delivers a half-empty crate. The fix is small (single compile_protos call with a slice), and I'd strongly encourage adding the type-presence smoke test in lib.rs so this can't regress silently.

The optional-keyword improvements for UpdateNodeRequest and version fields are not strictly blockers, but they avoid a known-imminent breaking proto change — please address node_types (repeated) and version (optional) at minimum before merge, since those will cost more later than they do now.

Once the blocker is fixed and the generated file contains both services, this is in good shape to land.

- Fix build.rs: compile both protos in one pass (NodeService was being
  overwritten by AgentSessionService in $OUT_DIR/nodespace.rs)
- Add pub use re-exports in lib.rs as compile-time presence check for
  both services (no allow attribute needed; pub use is idiomatic)
- Switch UpdateNodeRequest content/properties to proto3 optional so
  callers can distinguish "no change" (absent) from "clear value" (empty)
- Switch version fields in UpdateNodeRequest and DeleteNodeRequest to
  optional int64, replacing the version=0 sentinel with Option<i64>
- Switch SearchRequest node_type (singular) to node_types (repeated)
  to match SearchSemanticInput in the ops layer
- Switch NodeData.parent_id to optional string for root-node clarity
- Switch SessionInfo.exit_code to optional int32 so consumers can
  distinguish "running, no exit code yet" from "exited with code 0"
- Document JSON-string properties trade-off on NodeData.properties
- Document not-yet-exposed search fields on SearchRequest
- Use ? instead of unwrap() in build.rs

Skipped: crate rename (workspace prefix convention preferred), ChatResponse
oneof expansion (YAGNI), whitespace nit in schema.rs (not in PR scope).

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@malibio

malibio commented May 17, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed all review feedback from #1126 (comment) in commit 19a06f3.

What was fixed

Blocker (critical)

  • build.rs overwrite bug: Replaced the two separate tonic_build::compile_protos() calls with a single tonic_build::configure().compile_protos(&[...], &["proto"]) call. Both .proto files now compile into one nodespace.rs instead of the second overwriting the first.
  • unwrap() → ?: The protoc_bin_path() call now propagates errors properly.

Compile-time presence check (src/lib.rs)

  • Added pub use re-exports for NodeServiceClient, NodeServiceServer, AgentSessionServiceClient, AgentSessionServiceServer, NodeData, and SessionInfo. These serve as the compile-time smoke check — if either service is absent from the generated output, the crate fails to compile. No #[allow(dead_code)] needed; pub use is the idiomatic approach.

Proto improvements

  • UpdateNodeRequest: content and properties changed to optional string (distinguishes "no change" from "clear value"); version changed to optional int64 (replaces version=0 sentinel with Option<i64>, matching UpdateNodeInput).
  • DeleteNodeRequest: version changed to optional int64 for same reason.
  • SearchRequest: node_type: string renamed to node_types: repeated string to match the []string shape in SearchSemanticInput.
  • NodeData.parent_id: Changed to optional string so root nodes have an absent field rather than an empty string.
  • SessionInfo.exit_code: Changed to optional int32 so consumers can distinguish "running" (absent) from "exited with code 0" (present).
  • Doc comments: Added explanation of the JSON-string properties trade-off on NodeData.properties; documented the not-yet-exposed SearchSemanticInput fields on SearchRequest.

What was intentionally skipped

  • Crate rename (nodespace-daemon → daemon): Reviewer noted the workspace-consistent nodespace- prefix is preferred; keeping it as-is.
  • ChatResponse done → oneof with token usage: Reviewer applied YAGNI; the chat surface will be redesigned when the agent layer matures.
  • schema.rs:1020 whitespace nit: Reviewer said "not worth re-opening for."

Verification results

Check Result
cargo clean -p nodespace-daemon && cargo build -p nodespace-daemon PASS
Generated nodespace.rs contains CreateNodeRequest PASS (count=1)
Generated nodespace.rs contains LaunchSessionRequest PASS (count=1)
NodeServiceClient and AgentSessionServiceClient both present PASS
cargo test -p nodespace-daemon PASS (0 unit tests, 0 failures)
cargo clippy -p nodespace-daemon -- -D warnings PASS (clean)
cargo clippy --workspace --all-targets -- -D warnings PASS (clean)
bun run quality:fix PASS (no changes made)
bun run test:all (frontend) PASS: 128 files, 3918 tests
bun run test:all (Rust) PASS: 1182 tests

@malibio

malibio commented May 17, 2026

Copy link
Copy Markdown
Collaborator Author

Code Review Summary

Review Type: Re-Review

Prior review #1126 (comment)
Re-review commit 19a06f30
Prior counts 1 Blocker, 5 Improvements, 5 Nits
Prior status Request Changes

The author addressed the blocker and every recommended Improvement cleanly. The fix for the build.rs overwrite bug is correct and verifiably produces a nodespace.rs containing both NodeService and AgentSessionService (the prior review's smoke check now passes — 1 CreateNodeRequest, 1 LaunchSessionRequest, 11 NodeServiceClient/Server references, 11 AgentSessionServiceClient/Server references). pub use was used in place of an allow(dead_code) const — the better choice. Field tags were preserved across the proto edits. No new issues introduced.

This is a clean re-review with no remaining blockers and nothing further to address.


Previous Review Items Status

Blocker

  • ✅ build.rs overwrite bug — Fixed. Now uses a single tonic_build::configure().compile_protos(&[...], &["proto"]) call with both .proto files in the slice. Verified by greps against target/debug/build/nodespace-daemon-*/out/nodespace.rs:
    • pub struct CreateNodeRequest → 1 ✅
    • pub struct LaunchSessionRequest → 1 ✅
    • NodeServiceServer|NodeServiceClient → 11 ✅
    • AgentSessionServiceServer|AgentSessionServiceClient → 11 ✅

Improvements

  • ✅ Smoke-check / compile-time presence guard (lib.rs:25-29) — Added pub use re-exports for NodeServiceClient/Server, AgentSessionServiceClient/Server, NodeData, and SessionInfo. No #[allow(dead_code)] attribute used — pub use is the idiomatic, self-documenting form. Resolves the regression-detection concern from the prior review.
  • ✅ UpdateNodeRequest.content / properties — Switched to optional string. Generated code yields Option<String>, matching UpdateNodeInput in the ops layer.
  • ✅ UpdateNodeRequest.version / DeleteNodeRequest.version — Switched to optional int64 → Option<i64>. The version = 0 sentinel collision is gone.
  • ✅ SearchRequest shape — node_type (singular string) → node_types (repeated string), eliminating the known-imminent breaking change. Doc comment added listing not-yet-exposed SearchSemanticInput fields (exclude_collections, include_markdown, include_archived, scope, include_edges, graph_boost, property_filters).
  • ✅ NodeData.properties documentation — JSON-string vs google.protobuf.Struct trade-off documented inline.
  • ✅ build.rs .unwrap() → ? — protoc_bin_path()? propagates properly.

Nits

  • ✅ NodeData.parent_id → optional string — Done. Generated as Option<String>. Root nodes can now be unambiguously represented as absent rather than empty string.
  • ✅ SessionInfo.exit_code → optional int32 — Done. Generated as Option<i32>. Consumers can now distinguish "running, no exit code yet" from "exited with code 0."
  • ✅ #![allow(clippy::all)] scope (flagged in nits as no-action-needed) — Properly scoped to the generated nodespace module.
  • (Intentionally skipped, with reviewer agreement) Crate rename, ChatResponse oneof, schema.rs whitespace nit.

Field tag integrity check

The prior review's concern about silent renumbering: verified by inspecting the generated nodespace.rs. All tags preserved across the proto edits:

  • UpdateNodeRequest: 1=node_id, 2=version, 3=node_type, 4=content, 5=properties, 6=add_to_collection, 7=remove_from_collection, 8=lifecycle_status ✅
  • DeleteNodeRequest: 1=node_id, 2=version ✅
  • NodeData: 1-10 unchanged ✅
  • SearchRequest: 1-9 unchanged (just the type-cardinality on tag 2) ✅
  • SessionInfo: 1-10 unchanged ✅

pub use namespace leak check

The prior review asked whether the re-exports leak the whole nodespace proto namespace. Answer: they don't. lib.rs re-exports exactly six named symbols (NodeServiceClient, NodeServiceServer, AgentSessionServiceClient, AgentSessionServiceServer, NodeData, SessionInfo). The inner pub mod nodespace { ... } is independently public — that's by design so future workspace crates can reach the full generated tree under nodespace_daemon::nodespace::*. Targeted re-exports at the crate root + namespaced access to the rest is the right shape.


Verification Performed

Step Result
cargo clean -p nodespace-daemon OK (removed 136 files, 98.0 MiB)
cargo build -p nodespace-daemon PASS (1.62s, fresh codegen)
Generated nodespace.rs has CreateNodeRequest 1 hit ✅
Generated nodespace.rs has LaunchSessionRequest 1 hit ✅
Generated nodespace.rs has NodeServiceServer/Client 11 hits ✅
Generated nodespace.rs has AgentSessionServiceServer/Client 11 hits ✅
cargo test -p nodespace-daemon PASS (0 unit / 0 doc tests)
cargo clippy -p nodespace-daemon -- -D warnings CLEAN
cargo clippy --workspace --all-targets -- -D warnings CLEAN

Findings

Critical Issues

None.

Suggested Improvements

None.

Nitpicks

None blocking. Minor observations on the iteration:

  • Nit: The proto comment on UpdateNodeRequest.version (node_service.proto:86-88) says "Use 0 / unset rather than a sentinel". The 0 / is slightly confusing — with optional int64, the prost-generated Option<i64> makes the unset state explicit, and Some(0) is now a legitimate distinguishable value (no longer a sentinel). Consider trimming to "version unset = auto-fetch current version; matches UpdateNodeInput in the ops layer." Truly minor wording polish.

Recommendation

Approve / Ready to Merge. The blocker is resolved with verified codegen output, every recommended improvement landed, no field tags drifted, no new issues introduced, and clippy is clean workspace-wide. The single nit above is wording-only and not worth a follow-up commit on its own.

(Note: GitHub blocks formal gh pr review --approve on self-authored PRs, so this comment serves as the approval artifact.)

Reviewer flagged that the comment "Use 0 / unset rather than a sentinel"
was misleading now that the field is proto3 optional — Some(0) is a
legitimate, distinguishable value, not a sentinel. Trimmed to match the
DeleteNodeRequest.version phrasing.

Comment-only; no codegen impact.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@malibio

malibio commented May 17, 2026

Copy link
Copy Markdown
Collaborator Author

Address-review iteration 2 — final nit polish

Pushed 88eb6167 to address the single wording nit from the re-review:

  • proto/node_service.proto:86-88 — trimmed the UpdateNodeRequest.version comment. Replaced "Use 0 / unset rather than a sentinel" with phrasing that matches the DeleteNodeRequest.version comment ("version unset = auto-fetch current version; matches UpdateNodeInput in the ops layer. prost generates Option."). The old wording was a holdover from the pre-optional design and was misleading now that Some(0) is a legitimate, distinguishable value.

Comment-only change; no codegen impact. cargo build -p nodespace-daemon clean.

No re-review needed — single-line doc edit, zero functional change.

@malibio
malibio merged commit 9ab56fb into main May 17, 2026
@malibio
malibio deleted the feature/issue-1111-daemon-proto-pipeline branch May 17, 2026 14:28
malibio added a commit that referenced this pull request Jun 22, 2026
…1126)

* Add packages/daemon: protobuf schema and tonic/prost build pipeline (closes #1111)

Establishes the gRPC foundation for ADR-031 (daemon-client architecture).
No server handlers — just the crate skeleton, proto definitions, build.rs,
and re-exported generated types.

New files:
- packages/daemon/Cargo.toml — crate manifest with tonic 0.12 + prost 0.13
- packages/daemon/build.rs — tonic-build + protoc-bin-vendored (no system protoc)
- packages/daemon/proto/node_service.proto — NodeService: CreateNode, GetNode,
  UpdateNode, DeleteNode, GetChildren, SearchNodes, WatchNodes (server stream),
  Chat (bidirectional stream); message shapes aligned with packages/core/src/ops/
- packages/daemon/proto/agent_session_service.proto — AgentSessionService:
  LaunchSession, StreamOutput, WriteInput, ResizeTerminal, TerminateSession,
  ListSessions; PTY/terminal field shapes
- packages/daemon/src/lib.rs — re-exports generated nodespace module

Updated:
- Cargo.toml (workspace root) — add packages/daemon member
- packages/core/src/mcp/handlers/schema.rs — cargo fmt trailing newline removal

Proto message field shapes:
- node_id: string UUID
- node_type: string (e.g. "text", "task", "date")
- content: string
- properties: JSON-encoded string (matches ops layer Value serialisation)
- version: int64 (OCC counter; 0 = auto-fetch, matching ops-layer behaviour)
- lifecycle_status: string enum ("active" | "archived" | "deleted")

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* Address review feedback on PR #1126

- Fix build.rs: compile both protos in one pass (NodeService was being
  overwritten by AgentSessionService in $OUT_DIR/nodespace.rs)
- Add pub use re-exports in lib.rs as compile-time presence check for
  both services (no allow attribute needed; pub use is idiomatic)
- Switch UpdateNodeRequest content/properties to proto3 optional so
  callers can distinguish "no change" (absent) from "clear value" (empty)
- Switch version fields in UpdateNodeRequest and DeleteNodeRequest to
  optional int64, replacing the version=0 sentinel with Option<i64>
- Switch SearchRequest node_type (singular) to node_types (repeated)
  to match SearchSemanticInput in the ops layer
- Switch NodeData.parent_id to optional string for root-node clarity
- Switch SessionInfo.exit_code to optional int32 so consumers can
  distinguish "running, no exit code yet" from "exited with code 0"
- Document JSON-string properties trade-off on NodeData.properties
- Document not-yet-exposed search fields on SearchRequest
- Use ? instead of unwrap() in build.rs

Skipped: crate rename (workspace prefix convention preferred), ChatResponse
oneof expansion (YAGNI), whitespace nit in schema.rs (not in PR scope).

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* Polish UpdateNodeRequest.version doc comment

Reviewer flagged that the comment "Use 0 / unset rather than a sentinel"
was misleading now that the field is proto3 optional — Some(0) is a
legitimate, distinguishable value, not a sentinel. Trimmed to match the
DeleteNodeRequest.version phrasing.

Comment-only; no codegen impact.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

---------

Co-authored-by: Michael Libio <[email protected]>
Co-authored-by: Claude Sonnet 4.6 <[email protected]>
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.

Define protobuf schema and set up tonic/prost build pipeline for nodespaced

1 participant