Cargo Workspace & Single Binary CLI/API Scaffold #2
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Scaffold the single Cargo package producing the
lifebinary, providing foundational CLI entry points (life <command>), internal module boundaries, uniform JSON output envelopes, and the Axum HTTP service router scaffold as defined in the prospective architecture.Background & Technical Rationale
The Life architecture intentionally avoids distributed microservices, TypeScript/Python sidecars, MCP protocol wrappers, or heavy generic agent frameworks. Instead, a single Rust binary serves two operational roles:
life serve): An authenticated HTTP service exposing/v1/*routes, hosting background workers, and mediating access to SQLite, Radicale (CalDAV), Hindsight, and Jev.life <command>): A thin, authenticated HTTPS client that communicates withlife serveover the local network or unix domain socket, parsing command-line arguments and rendering structured JSON.A uniform communication contract governs all CLI outputs and HTTP endpoints. The CLI must output exactly one JSON envelope on
stdoutwhen invoked with--json, while all diagnostic, trace, and logging output is routed strictly tostderr. Diagnostics must never contain authentication tokens or private item payloads.The CLI chooses semantic exit codes (e.g., exit code 6 for pending/partial operations, exit code 4 for concurrency conflicts) matching the HTTP transport semantics defined in the technical specification.
Exact Technical References & Specifications
Process Model
From
docs/technical/architecture.md#process-model:Implementation Boundaries & Layout
From
docs/technical/architecture.md#implementation-boundaries:Prospective layout:
Transport and Common Contract
From
docs/technical/cli-api.md#transport-and-common-contract:Exit Code to HTTP Mapping Table
From
docs/technical/cli-api.md#transport-and-common-contract:Command-to-Route Mapping Table
From
docs/technical/cli-api.md#command-to-route-table:life agenda --period today|tomorrow|weeklife tasks listlife item get IDlife task add --input -life task update ID --etag ETAG --input -life task complete ID --etag ETAG --operation-id KEY --input -life task reopen ID --etag ETAG --input -life task cancel ID --etag ETAG --input -life event add --input -life event update ID --etag ETAG --input -life event cancel ID --etag ETAG --input -life capture --input -life resolve --text TEXT --kind task|eventlife plan --period today|week --input -life next --window 90m --energy mediumlife replan --input -life review --period weeklife context add --input -life context search --input -life timelinelife proposal get IDlife proposal apply ID --input -life proposal reject ID --input -life operation get IDlife sync --input -life doctorlife serveFormal Section Citations
docs/technical/architecture.md#process-model: Details the single-binary architecture and service interactions.docs/technical/architecture.md#implementation-boundaries: Normative table for dependencies and prospective code organization.docs/technical/cli-api.md#transport-and-common-contract: Defines JSON envelope attributes, stderr log routing, and the exit code mapping.docs/technical/cli-api.md#command-to-route-table: Full mapping of CLI commands to Axum HTTP routes and auth scopes.docs/technical/development.md#implementation-sequencing: Guides the scaffolding phase before domain and adapter expansion.What to Build (Step-by-Step)
Initialize
Cargo.toml:life(edition 2021 or 2024).tokio = { version = "1", features = ["full"] }axum = { version = "0.7", features = ["macros"] }clap = { version = "4", features = ["derive", "env"] }serde = { version = "1.0", features = ["derive"] }serde_json = "1.0"tracing = "0.1"tracing-subscriber = { version = "0.3", features = ["env-filter", "json"] }thiserror = "1.0"uuid = { version = "1", features = ["v4"] }Setup Entry Point & Logging (
src/main.rs):tracing_subscriberto send all logs tostd::io::stderr.clap.life servedaemon handler or CLI client dispatch.docs/technical/cli-api.md#transport-and-common-contract.Define CLI Commands & JSON Envelope (
src/cli.rs):Cliderive struct with subcommands:serve,doctor,agenda,tasks,item,task,event,capture,resolve,plan,next,replan,review,context,timeline,proposal,operation,sync.emit_json<T>(envelope: ResponseEnvelope<T>, exit_code: i32)which serializes tostdoutfollowed by a single newline.Define Service Router Scaffold (
src/api.rs):Routerbinding:GET /health/liveGET /health/ready/v1/*routes returning501 Not Implementedwrapped in standardResponseEnvelope.request_id(X-Request-ID) and inject into tracing span.Establish Core Directory Module Skeletons:
src/domain/mod.rs: pure domain identities and value types.src/calendar/mod.rs: CalDAV and iCalendar preservation logic.src/history/mod.rs: SQLite worker, schema migrations, outbox.src/config.rs: configuration models.Format & Linter Checks:
cargo check,cargo fmt --check, andcargo clippy --all-targets -- -D warningsrun with zero errors.Acceptance Criteria
cargo buildproduces the single executabletarget/debug/life.life --helplists all prospective subcommands matchingdocs/technical/cli-api.md#command-to-route-table.--jsonoutputs a valid JSON envelope withschema_version: 1,request_id,status,data,warnings,errorstrictly onstdout.tracingprints exclusively tostderr, leavingstdoutpure JSON parseable byjq.cargo fmt --checkandcargo clippy --all-targets -- -D warningspass cleanly.Blocked by
Issue #002: Cargo Workspace & Single Binary CLI/API Scaffoldto Cargo Workspace & Single Binary CLI/API Scaffold