Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions crates/cockpit-server/src/codebook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ use std::hash::{Hash, Hasher};
///
/// Both this crate and `lance-graph`'s thinking engine assume the same
/// codebook width when exchanging `u16` indices. Keep in sync.
#[allow(
dead_code,
reason = "codebook token-index surface (Cypher identifier extraction -> stable u16 index); built out but no call site wires it yet; allow not expect — used under cfg(test)/feature, so no expectation holds in every --all-targets compilation"
)]
pub const CODEBOOK_SIZE: usize = 4096;

/// Synthetic placeholder distance table for `ThinkingEngine::new`.
Expand All @@ -31,18 +35,30 @@ pub const CODEBOOK_SIZE: usize = 4096;
///
/// Cost: 4096 × 4096 × 1 byte = 16 MB. Allocated once per cockpit-server
/// boot (per SSE connection in the current handler).
#[expect(
dead_code,
reason = "codebook token-index surface; PHASE 2A stub distance table for ThinkingEngine::new, built out but no call site wires it yet"
)]
pub fn default_distance_table() -> Vec<u8> {
vec![0u8; CODEBOOK_SIZE * CODEBOOK_SIZE]
}

/// Cypher keywords excluded from identifier extraction.
#[allow(
dead_code,
reason = "codebook token-index surface; keyword exclusion list for extract_cypher_identifiers, built out but no call site wires it yet; allow not expect — used under cfg(test)/feature, so no expectation holds in every --all-targets compilation"
)]
const CYPHER_KEYWORDS: &[&str] = &[
"MATCH", "RETURN", "WHERE", "CREATE", "MERGE", "SET", "DELETE", "AS", "AND", "OR", "NOT",
"NULL", "TRUE", "FALSE", "OPTIONAL", "WITH", "UNWIND", "ORDER", "BY", "ASC", "DESC", "LIMIT",
"SKIP", "COUNT", "COLLECT", "DISTINCT",
];

/// Maximum identifiers returned by [`extract_cypher_identifiers`] per call.
#[allow(
dead_code,
reason = "codebook token-index surface; per-call cap for extract_cypher_identifiers, built out but no call site wires it yet; allow not expect — used under cfg(test)/feature, so no expectation holds in every --all-targets compilation"
)]
const MAX_IDENTIFIERS_PER_CALL: usize = 32;

/// Map a token to a stable `u16` codebook index in `[0, CODEBOOK_SIZE)`.
Expand All @@ -51,6 +67,10 @@ const MAX_IDENTIFIERS_PER_CALL: usize = 32;
/// deterministic within a single process run; callers must not rely on
/// stability across Rust toolchain versions, since `DefaultHasher` is not
/// guaranteed stable across releases.
#[allow(
dead_code,
reason = "codebook token-index surface; stable token->u16 index mapping, built out but no call site wires it yet; allow not expect — used under cfg(test)/feature, so no expectation holds in every --all-targets compilation"
)]
pub fn token_to_index(token: &str) -> u16 {
let mut hasher = DefaultHasher::new();
token.hash(&mut hasher);
Expand All @@ -63,6 +83,10 @@ pub fn token_to_index(token: &str) -> u16 {
/// Preserves first-occurrence order: if two distinct tokens hash to the same
/// index, both appear once in input order, but duplicate tokens collapse to
/// a single index in the output.
#[allow(
dead_code,
reason = "codebook token-index surface; batch token->indices dedup helper, built out but no call site wires it yet; allow not expect — used under cfg(test)/feature, so no expectation holds in every --all-targets compilation"
)]
pub fn tokens_to_indices(tokens: &[&str]) -> Vec<u16> {
let mut seen: HashSet<&str> = HashSet::with_capacity(tokens.len());
let mut out: Vec<u16> = Vec::with_capacity(tokens.len());
Expand All @@ -80,6 +104,10 @@ pub fn tokens_to_indices(tokens: &[&str]) -> Vec<u16> {
/// start with an ASCII letter and have length >= 2, drops Cypher keywords
/// (case-insensitive), deduplicates while preserving first-occurrence
/// order, and caps the output at [`MAX_IDENTIFIERS_PER_CALL`] entries.
#[allow(
dead_code,
reason = "codebook token-index surface; Cypher identifier extraction for the scene player/shader stream, built out but no call site wires it yet; allow not expect — used under cfg(test)/feature, so no expectation holds in every --all-targets compilation"
)]
pub fn extract_cypher_identifiers(content: &str) -> Vec<String> {
let mut seen: HashSet<String> = HashSet::new();
let mut out: Vec<String> = Vec::new();
Expand Down
8 changes: 8 additions & 0 deletions crates/cockpit-server/src/graph_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,18 @@ pub struct GraphEdge {

impl GraphEdge {
/// Convenience: legacy `truth_f` accessor for in-process consumers.
#[expect(
dead_code,
reason = "legacy accessor for in-process consumers; the wire Serialize impl reads self.truth.frequency/.confidence directly, so nothing calls this yet"
)]
pub fn truth_f(&self) -> f32 {
self.truth.frequency
}
/// Convenience: legacy `truth_c` accessor for in-process consumers.
#[expect(
dead_code,
reason = "legacy accessor for in-process consumers; the wire Serialize impl reads self.truth.frequency/.confidence directly, so nothing calls this yet"
)]
pub fn truth_c(&self) -> f32 {
self.truth.confidence
}
Expand Down
30 changes: 30 additions & 0 deletions crates/cockpit-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ use std::time::Duration;

use axum::extract::State;
use axum::http::StatusCode;
#[cfg(feature = "embed-cockpit")]
use axum::http::header;
use axum::response::sse::{Event, Sse};
use axum::response::{Html, IntoResponse, Response};
use axum::routing::{get, post};
Expand Down Expand Up @@ -149,6 +151,10 @@ struct SseEvent {

#[derive(Debug, Deserialize)]
struct McpRequest {
#[expect(
dead_code,
reason = "part of the JSON-RPC 2.0 envelope; required for serde to parse incoming requests per the wire schema, but the value itself is never consulted"
)]
jsonrpc: String,
id: serde_json::Value,
method: String,
Expand Down Expand Up @@ -523,6 +529,10 @@ async fn shutdown_signal() {
/// filename for a known slug, `None` for unknown/malformed ones. Slugs are
/// lowercase `[a-z0-9-]` — anything else is rejected before the map lookup
/// (no path traversal into the dist).
#[allow(
dead_code,
reason = "Garmin terrain-scene resolution surface; only call sites are under cfg(feature = \"embed-cockpit\") and cfg(test), so a default build sees no reference; allow not expect — used under cfg(test)/feature, so no expectation holds in every --all-targets compilation"
)]
fn resolve_garmin_map(manifest_json: &str, map_key: &str, location: &str) -> Option<String> {
if location.is_empty()
|| !location
Expand All @@ -535,25 +545,41 @@ fn resolve_garmin_map(manifest_json: &str, map_key: &str, location: &str) -> Opt
v.get(map_key)?.get(location)?.as_str().map(String::from)
}

#[allow(
dead_code,
reason = "Garmin terrain-scene resolution surface; only call sites are under cfg(feature = \"embed-cockpit\") and cfg(test), so a default build sees no reference; allow not expect — used under cfg(test)/feature, so no expectation holds in every --all-targets compilation"
)]
fn resolve_garmin_scene(manifest_json: &str, location: &str) -> Option<String> {
resolve_garmin_map(manifest_json, "garmin_scenes", location)
}

/// Resolve a `/garmin-drape/:location` slug through the manifest's `garmin_drapes`
/// map — the DRP1 vector overlay (roads / trails / rivers) that drapes onto the
/// `garmin_scenes` terrain of the same slug. Absent = the scene has no drape.
#[allow(
dead_code,
reason = "Garmin terrain-scene resolution surface; only call sites are under cfg(feature = \"embed-cockpit\") and cfg(test), so a default build sees no reference; allow not expect — used under cfg(test)/feature, so no expectation holds in every --all-targets compilation"
)]
fn resolve_garmin_drape(manifest_json: &str, location: &str) -> Option<String> {
resolve_garmin_map(manifest_json, "garmin_drapes", location)
}

/// Resolve a `/garmin-contours/:location` slug through the manifest's
/// `garmin_contours` map — the DRP1 topo-line overlay that drapes onto the
/// `garmin_scenes` terrain of the same slug. Absent = the scene has no contours.
#[allow(
dead_code,
reason = "Garmin terrain-scene resolution surface; only call sites are under cfg(feature = \"embed-cockpit\") and cfg(test), so a default build sees no reference; allow not expect — used under cfg(test)/feature, so no expectation holds in every --all-targets compilation"
)]
fn resolve_garmin_contours(manifest_json: &str, location: &str) -> Option<String> {
resolve_garmin_map(manifest_json, "garmin_contours", location)
}

/// List the available scene slugs (for the self-documenting 404).
#[allow(
dead_code,
reason = "Garmin terrain-scene resolution surface; only call sites are under cfg(feature = \"embed-cockpit\") and cfg(test), so a default build sees no reference; allow not expect — used under cfg(test)/feature, so no expectation holds in every --all-targets compilation"
)]
fn garmin_scene_slugs(manifest_json: &str) -> Vec<String> {
serde_json::from_str::<serde_json::Value>(manifest_json)
.ok()
Expand Down Expand Up @@ -746,6 +772,10 @@ async fn static_handler(uri: axum::http::Uri) -> Response {
(StatusCode::NOT_FOUND, "Not found").into_response()
}

#[allow(
dead_code,
reason = "MIME lookup utility; sole call site is inside the cfg(feature = \"embed-cockpit\") static_handler block; allow not expect — with that feature enabled the call exists, so no expectation holds in every configuration"
)]
fn mime_from_path(path: &str) -> &'static str {
if path.ends_with(".html") {
"text/html; charset=utf-8"
Expand Down
Loading
Loading