diff --git a/doc/2026-11-24T01-44-52Z_feature_capability_connect_verdict/2026-11-24T01-44-52Z_feature_capability_connect_verdict.md b/doc/2026-11-24T01-44-52Z_feature_capability_connect_verdict/2026-11-24T01-44-52Z_feature_capability_connect_verdict.md new file mode 100644 index 0000000000..dbc5051a88 --- /dev/null +++ b/doc/2026-11-24T01-44-52Z_feature_capability_connect_verdict/2026-11-24T01-44-52Z_feature_capability_connect_verdict.md @@ -0,0 +1,7 @@ +# Capability connect verdict + +Issue #12921's connect-stage decision is a bounded pure slice of the capability-change notice. The world client currently does not resolve release and instance records, so this change will not wire the decision into a live connection pipeline or claim persistence/UI behavior. + +The `id-caps` API will decide from a known baseline, release identity, the current shipped class-table version, and an optional freshly computed message set. First connect returns the classes for the disclosure flow. A matching release and class-table version short-circuits silently. Otherwise, missing computation fails closed with the existing `unknown` diff; a covered set proceeds and reports whether it is strictly different (for narrowing bookkeeping); an uncovered set holds with exactly the diff's new classes. + +The class-table version is `CAP_CLASS_TABLE_VERSION` in `cap_class.rs`; consumers do not supply or duplicate it. Actual manifest resolution, connection holding, persistence, and user interaction remain follow-on integration work. diff --git a/doc/README.md b/doc/README.md index 5a3803eb6f..5566d347bc 100644 --- a/doc/README.md +++ b/doc/README.md @@ -60,6 +60,7 @@ This list is the workflow's request catalog (`request_catalog` in [`.agents/rese ## Dated records +- [Capability connect verdict](2026-11-24T01-44-52Z_feature_capability_connect_verdict/2026-11-24T01-44-52Z_feature_capability_connect_verdict.md) — the pure connect-stage outcome for first connect, same-release/table short-circuit, covered narrowing, uncovered notice holds, and fail-closed comparison inputs (#12921). - [#5670 phase 1 — Atlas Python reference + eval corpus migration: verification and close-out](2026-11-24T06-23-32Z_report_id5670_phase1_atlas_python_migration/2026-11-24T06-23-32Z_report_id5670_phase1_atlas_python_migration.md) — the 2026-11-07 landing of `atlas_search.py`, `eval3.py` and the golden-311 corpus into `pkgs/atlas-search/` verified against the outside sources (SHA-256 provenance match, AST identity, JSON identity), the full §8 inventory at 2026-11-24, and the remainder sliced as #14128–#14132 (tracking #5670). - [ID-graph publication format, 9-point sufficiency record for #6062](2026-11-24T06-10-00Z_design_6062_idgraph_publication/2026-11-24T06-10-00Z_design_6062_idgraph_publication.md) — sufficiency wrapper for #6062 (tracking #13873, task 21677): goals/non-goals, alternatives incl. do-nothing, the chosen publication contract, slices S1-S5 mapped to #11182-#11186, rollout/rollback, oracles, named-decider defaults. Technical core unchanged: doc/2026-11-09T07-20-00Z_design_atlas_id_publication/ (PR #7998). Design-only, closes nothing. - [Standing auto-update system](2026-11-24T06-25-30Z_design_auto-update-system/2026-11-24T06-25-30Z_design_auto-update-system.md) — design of record for #14134 (Drew's order, 2026-11-24): every daemon, binary and service on the laptop, the Muse sandbox seat, and Cloudflare kept automatically updated — pin, converge, verify, fail safe. The laptop's NixOS build is the rectifier; home-manager overrides are recorded in a ledger and rectified by the next build under a hard no-silent-revert rule; sandbox seats converge to the bootstrap pin at safe windows; every Cloudflare Worker joins the build, health-gate, promote pipeline (composing with #14107 for the PM surfaces); one daily drift census across all three planes; the package-everything rule with today's contradictions named (fleet's package exists but its deployment is a hand-copied binary; the vendor self-updaters claude and codex are exception-listed); slice map U1–U7 (not queued). diff --git a/pkgs/id/crates/id-caps/src/cap_baseline.rs b/pkgs/id/crates/id-caps/src/cap_baseline.rs index 14e8e830dd..2fc96b27e3 100644 --- a/pkgs/id/crates/id-caps/src/cap_baseline.rs +++ b/pkgs/id/crates/id-caps/src/cap_baseline.rs @@ -45,7 +45,8 @@ use std::collections::{BTreeMap, BTreeSet}; use serde::{Deserialize, Serialize}; use sha2::{Digest, Sha256}; -use crate::cap_diff::{CapDiff, compare}; +use crate::cap_class::CAP_CLASS_TABLE_VERSION; +use crate::cap_diff::{CapDiff, compare, uncomputable_diff}; /// How a baseline came to hold the message set it holds — the /// `kind` of a history entry (#5959 §1, §5). Every transition that @@ -113,6 +114,79 @@ pub struct CapBaseline { pub history: Vec, } +/// Pure connect-stage outcome for a freshly resolved release. +/// +/// This decides whether the caller may proceed, needs the first-connect +/// disclosure flow, or must hold for a capability-change notice. It does +/// not resolve manifests, persist a narrowed baseline, or control a live +/// connection. +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum ConnectVerdict { + /// There is no accepted baseline; disclose this complete message set + /// and let the first-connect flow record the user's decisions. + FirstConnect { message_set: Vec }, + /// The baseline already describes this release under the current + /// class table, so no comparison or notice is needed. + SameReleaseAndTable, + /// The computed set is covered by the baseline. `narrowed` tells the + /// caller whether automatic narrowing bookkeeping is applicable. + Proceed { + message_set: Vec, + narrowed: bool, + }, + /// The connection must be held; the diff names exactly the classes + /// the notice needs to disclose. + Hold(CapDiff), +} + +/// Decide the connect-stage capability outcome from already resolved +/// inputs. `message_set` is `None` when release/manifest/class comparison +/// could not be computed; that path fails closed with the `unknown` class. +/// +/// A baseline for the same release and shipped class-table version +/// short-circuits before requiring a computed set. Other outcomes use the +/// same table version recorded by the shipped vocabulary, rather than a +/// caller-supplied version that could disagree with it. +#[must_use] +pub fn evaluate_connect( + baseline: Option<&CapBaseline>, + release_identity: &str, + message_set: Option<&BTreeSet<&str>>, +) -> ConnectVerdict { + let Some(baseline) = baseline else { + return match message_set { + Some(message_set) => ConnectVerdict::FirstConnect { + message_set: message_set + .iter() + .map(|class| (*class).to_owned()) + .collect(), + }, + None => ConnectVerdict::Hold(uncomputable_diff()), + }; + }; + + if baseline.release_identity == release_identity + && baseline.table_version == CAP_CLASS_TABLE_VERSION + { + return ConnectVerdict::SameReleaseAndTable; + } + + let Some(message_set) = message_set else { + return ConnectVerdict::Hold(uncomputable_diff()); + }; + let diff = baseline.evaluate(message_set); + if diff.triggers() { + return ConnectVerdict::Hold(diff); + } + ConnectVerdict::Proceed { + narrowed: *message_set != baseline.message_set(), + message_set: message_set + .iter() + .map(|class| (*class).to_owned()) + .collect(), + } +} + /// Lowercase hex digits, for the baseline key's encoding. const HEX: &[u8; 16] = b"0123456789abcdef"; @@ -378,7 +452,9 @@ impl BaselineStore { #[allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)] mod tests { use super::*; - use crate::cap_class::{CLASS_CHAT_READ, CLASS_CHAT_WRITE, CLASS_DEVICE_LOCATION}; + use crate::cap_class::{ + CLASS_CHAT_READ, CLASS_CHAT_WRITE, CLASS_DEVICE_LOCATION, CLASS_UNKNOWN, + }; const AT: &str = "2026-11-23T06:00:00Z"; @@ -607,4 +683,62 @@ mod tests { assert_eq!(round_tripped, baseline); assert!(round_tripped.key_is_current()); } + + #[test] + fn connect_verdict_covers_first_connect_short_circuit_narrowing_and_hold() { + // Oracle: #5999 §4/#5959 §2 — no baseline enters first-connect + // disclosure; an identical release/table skips recomputation. + assert_eq!( + evaluate_connect(None, "release-a", Some(&refs(&[CLASS_CHAT_READ]))), + ConnectVerdict::FirstConnect { + message_set: vec![CLASS_CHAT_READ.to_owned()], + } + ); + assert_eq!( + evaluate_connect(Some(&baseline()), "release-a", None), + ConnectVerdict::SameReleaseAndTable + ); + + // Oracle: #5999 §4 rule 1/#5959 §5 path 4 — covered sets + // proceed, and a strict shrink is marked for narrowing. + assert_eq!( + evaluate_connect( + Some(&baseline()), + "release-b", + Some(&refs(&[CLASS_CHAT_READ])), + ), + ConnectVerdict::Proceed { + message_set: vec![CLASS_CHAT_READ.to_owned()], + narrowed: true, + } + ); + + // Oracle: #5999 §6 — an uncovered reconnect holds and names + // exactly the newly uncovered class. + assert_eq!( + evaluate_connect( + Some(&baseline()), + "release-b", + Some(&refs(&[CLASS_CHAT_READ, CLASS_DEVICE_LOCATION])), + ), + ConnectVerdict::Hold(CapDiff { + new_classes: vec![CLASS_DEVICE_LOCATION.to_owned()], + }) + ); + } + + #[test] + fn connect_verdict_fails_closed_when_computation_is_unavailable() { + // Oracle: #5999 §7 invariant 10 — missing comparison input is a + // hold whose sole disclosed class is unknown, even on first connect. + let accepted = baseline(); + for baseline in [None, Some(&accepted)] { + assert_eq!( + evaluate_connect(baseline, "release-b", None), + ConnectVerdict::Hold(CapDiff { + new_classes: vec![CLASS_UNKNOWN.to_owned()], + }) + ); + } + } } diff --git a/pkgs/id/crates/id-caps/src/world_caps.rs b/pkgs/id/crates/id-caps/src/world_caps.rs index 68ed54d9d6..402400f7b2 100644 --- a/pkgs/id/crates/id-caps/src/world_caps.rs +++ b/pkgs/id/crates/id-caps/src/world_caps.rs @@ -1002,12 +1002,8 @@ const TEST_PROVIDER_MANIFEST: ProviderManifest = ProviderManifest { mod client; pub use client::{ - CLIENT_CATALOG_ENTRIES, - CLIENT_FILE_READ_MANIFEST, - CLIENT_FILE_READ_NAME, - CLIENT_NOTIFY_MANIFEST, - CLIENT_NOTIFY_NAME, - MAX_CLIENT_FILE_READ_BYTES, + CLIENT_CATALOG_ENTRIES, CLIENT_FILE_READ_MANIFEST, CLIENT_FILE_READ_NAME, + CLIENT_NOTIFY_MANIFEST, CLIENT_NOTIFY_NAME, MAX_CLIENT_FILE_READ_BYTES, MAX_CLIENT_NOTIFY_RESPONSE_BYTES, };