5.5 KiB
5.5 KiB
P0 — Foundation
| Field | Value |
|---|---|
| Status | Ready |
| Owner | — |
| Phase | 0 (blocking, single track) |
| Depends on | — |
| Blocks | Every other card |
| Owned files | Cargo.toml, devenv.nix, config.example.toml, src/main.rs, src/config.rs, src/error.rs, src/state.rs, src/sources/mod.rs, src/sources/fake.rs, initial stubs of every other module |
Goal
Fix every contract that parallel work depends on: dependencies, config shape, DTOs, source traits, error type, AppState, and module signatures. After P0, no other card should need to touch Cargo.toml, main.rs or sources/mod.rs, except by agreed exception.
Keep it small. Stubs contain todo!() and no logic.
Tasks
Tick these in TODO.md.
- P0-1 devenv. Keep
languages.rust.enableand the existingCLAUDE_CONFIG_DIRenterShell. Addpkgs.pkg-configandpkgs.systemd(its.devoutput provideslibsystemd.pc). Addscripts.build,scripts.runandscripts.token, which wrapscargo run -- token. Do not add openssl. Optionally addpkgs.opentelemetry-collector-contribfor G7. - P0-2 Cargo.toml. Package
skyg-linux-trackerwith[[bin]] name = "slinuxm"(DEC-1). Pin every crate needed by all phases:- Runtime:
tokio(full),tokio-util(CancellationToken),futures. - HTTP:
axum0.8,tower,tower-http(trace). - Data:
serde,serde_json,schemars,thiserror,jifforchrono. - Config/CLI:
figment(toml,env),clap(derive,env). - MCP:
rmcp(server,macros,schemars,transport-streamable-http-server). - systemd/journal:
zbus,zbus_systemd(systemd1),systemd(journal, default features off where possible). - Docker:
bollard, no TLS features needed for a unix socket. - OTel:
opentelemetry,opentelemetry_sdk,opentelemetry-otlp(grpc-tonic,http-proto, rustls),tracing,tracing-subscriber,tracing-opentelemetry. - Auth:
sqlx(runtime-tokio,sqlite),sha2,rand,base64. - Optional:
async-trait. - Release profile:
lto = true,strip = true,codegen-units = 1.
- Runtime:
- P0-3 API spike, max half a day. Confirm against the pinned versions:
- The rmcp
StreamableHttpService::newsignature,StreamableHttpServerConfigfields, and whether it validates Origin or Host (DEC-8). - zbus_systemd
ManagerProxy,UnitProxy,ServiceProxy,TimerProxynames and property types. - The
systemdcrate journal open API,waitwith timeout, namespace support, and whetherJournalisSend. - bollard feature flags that avoid pulling openssl or rustls when only the unix socket is used.
- The opentelemetry-otlp builder API for headers and protocol selection.
- Record findings in the log below.
- The rmcp
- P0-4 config.rs. Use figment
Serialized::defaults<Toml::file<Env::prefixed("SKYG_").split("__")< CLI overrides. Key additions overplan.md:otel.headers(map)otel.metrics.units/otel.metrics.containers(glob allowlists)limits.max_lines(default 1000),limits.max_tail(default 1000),limits.max_follow_secs(default 60)- Validation: reject
auth.enabled = falsewhenbindis not loopback.
- P0-5 config.example.toml. Document every key with a comment and its env-var name.
- P0-6 DTOs in
src/sources/mod.rs:UnitSummary,UnitStatus(service fieldsOption),TimerInfoJournalQuery,JournalEntry,Priority(0–7, parse from name or number)ContainerSummary,ContainerStatus,LogLine { stream: Stdout|Stderr, ts, message }- All derive
Serialize,JsonSchemaandDebug. Timestamps serialize as RFC3339.
- P0-7 Traits + fakes.
SystemdSource,JournalSource,DockerSource. Follow methods returnmpsc::Receiveror a boxedStream.fake.rsprovides fixture-backed implementations for tests (DEC-2). - P0-8 error.rs.
AppError { NotFound, BadRequest, Unauthorized, Unavailable, Internal }. ImplementIntoResponse(status +{"error": {"code", "message"}}) andFrom<AppError> for rmcp::ErrorData. - P0-9 state.rs.
AppState { config: Arc<Config>, systemd: Arc<dyn SystemdSource>, journal: Arc<dyn JournalSource>, docker: Arc<dyn DockerSource>, db: Option<SqlitePool>, shutdown: CancellationToken }. Must beClone. - P0-10 Stubs with final signatures:
api::router(AppState) -> Routermcp::service(AppState) -> StreamableHttpService<…>telemetry::init(&Config) -> Result<TelemetryGuard>auth::layer(AppState)auth::tokens::run(TokenCmd, &Config) -> Result<()>db::open(&Config) -> Result<SqlitePool>- Source constructors in
sources/{systemd,journal,docker}.rs. main.rsdispatchesslinuxm serve(default),slinuxm token …, and--print-config.
- P0-11 Tests. Defaults only, file overrides defaults, env overrides file, CLI overrides env. The auth-off +
0.0.0.0combination is an error.
Done when
cargo run -- serve --print-configprints the merged config, and precedence works by hand.cargo buildproducestarget/debug/slinuxm.cargo clippy -- -D warnings,cargo fmt --checkandcargo testare clean.cargo tree -i opensslandcargo tree -i openssl-sysprint nothing.- Spike findings are recorded below and DEC-8 is updated.
Risks
- Changing DTOs after Phase 1 starts causes merge pain in four places. Spend the time here.
- rmcp moves fast. Pin the exact version and note it in the log.
Log
- 2026-10-15: Card created from
plan.mdreview. DEC-1 decided: CLI isslinuxm.