From cf840a6d0ff7c0ccf5b98cd2168598c6fc3c4d99 Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Mon, 23 Nov 2026 19:47:55 -0600 Subject: [PATCH 1/2] Add capability connect verdict --- ...-52Z_feature_capability_connect_verdict.md | 7 + doc/README.md | 2 + pkgs/id/crates/id-caps/src/cap_baseline.rs | 138 +++++++++++++++++- 3 files changed, 145 insertions(+), 2 deletions(-) create mode 100644 doc/2026-11-24T01-44-52Z_feature_capability_connect_verdict/2026-11-24T01-44-52Z_feature_capability_connect_verdict.md 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 a602e119ac..5151baab4c 100644 --- a/doc/README.md +++ b/doc/README.md @@ -55,6 +55,8 @@ 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). + Folders are named `__`. The kinds in use are `feature`, `design`, `architecture`, `phase`, `fix`, `reference`, `research` and `report`. A `report` record is the usual home for lane work product — a report or one-off with all of its gathered material in the folder; [`DOCUMENTATION_PROTOCOL.md`](DOCUMENTATION_PROTOCOL.md) gives the landing rules. Run `ls doc/` to list them all. Some starting points: - [Code Book programme — Census B merged priority list](2026-11-24T00-55-23Z_research_code-book-census-priorities/2026-11-24T00-55-23Z_research_code-book-census-priorities.md) — research record for #13905 (census 2026-11-23/24): the merged, dependency-ordered priority list for the Code Book programme — 30 items ordered execution substrate (fleet) first, then physical substrate (lab), data substrate, search intelligence (Atlas×ID), the ID platform build-out, gateway/PM/fork surfaces, and the record itself — each item with its type, status and evidence, most-related issues, and ordering rationale, plus a per-book assignment table (fleet 4 · atlas 8 · id 9 · mcpx 1 · pm 4 · lab 4), timing notes that invent no dates, and the census gaps carried forward (service-worker/offline and switches have no owning issue; the #10706/#10708 discovery blocker is unverified). 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()], + }) + ); + } + } } From a4776dddda3a92e814adddde60019489750ca24e Mon Sep 17 00:00:00 2001 From: repo-worker-code Date: Tue, 24 Nov 2026 03:39:25 -0600 Subject: [PATCH 2/2] id-caps: cargo fmt (fmt check fix for #13999) --- pkgs/id/crates/id-caps/src/world_caps.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) 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, };