Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
d1cc183
feat: relay host context to consequence reviews
senamakel Oct 22, 2026
e022e1e
chore(vendor): bump agent-browser, agent-desktop, tinybus and tinyinf…
senamakel Oct 22, 2026
826a885
docs(specs): document host context relay in desktop module contract
senamakel Oct 22, 2026
b1b67c6
chore(deps): refresh Cargo.lock
senamakel Oct 22, 2026
dc77292
fix(deps): restore compatible vendor pins
senamakel Oct 22, 2026
0897cd3
test(consequence_gate): mark review interface as confidential
senamakel Oct 22, 2026
aacc758
fix(consequence_gate): call review without confidential flag
senamakel Oct 22, 2026
32d5b6e
test(task): add host context to describe test fixture
senamakel Oct 22, 2026
89fd8d9
feat(task): add host_context field to continue task schema
senamakel Oct 22, 2026
611a563
test(consequence_gate): cover host context denial for unconfidential …
senamakel Oct 22, 2026
3c41a8c
feat(tinybus_module): route consequence reviews to a confidential host
senamakel Oct 22, 2026
46e3f51
docs(tinybus_module): document confidential consequence reviews
senamakel Oct 22, 2026
3ca0865
fix(task): omit host-only context from continue task schema
senamakel Oct 22, 2026
f05687a
test(task): cover continuation request fields in describe schemas
senamakel Oct 22, 2026
18ab9ea
fix(consequence): fail closed for missing configured callback
senamakel Oct 22, 2026
52e3596
docs(consequence): describe callback configuration and denial scope
senamakel Oct 22, 2026
e172609
fix(consequence): satisfy workspace clippy
senamakel Oct 22, 2026
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
3 changes: 3 additions & 0 deletions MODULE.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ is optional:
and requested task reports. Sink mode replaces local trace/session storage
and does not fall back to `trace_path`; event errors follow `trace_strict`,
and report write errors return a recoverable `TRACE_SINK_FAILED` response;
- `consequence_host`: an object containing only the unique destination prepared
for the confidential `ConsequenceHost` callback. When reviewing an approved
pending action, a missing object, interface, or failed callback declines it;
- `jev`: the decision model and its API key, needed by the Jev-driven and
task members. `provider` picks it: Jev through `type_safe` (the default),
`open_router`, or `tiny_humans_open_router`; `open_jev` (OpenJEV's
Expand Down
6 changes: 6 additions & 0 deletions crates/tinycomputer-bus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,9 @@ distinguish causal re-entry from unrelated concurrent work. Event
and artifact acknowledgements are bounded by the engine's operation deadline;
report calls have a ten-second transport timeout. A host that does not opt in
keeps the existing desktop file/session trace behavior.

Contract 2.27 adds an opaque host context to `ContinueTask` and relays it
unchanged to `ConsequenceHost.Review`. TinyComputer does not interpret the
context or grant it authority; hosts can use it to recover trusted caller
context while reviewing an approval. Hosts that depend on this relay must
reject modules older than 2.27.
22 changes: 22 additions & 0 deletions crates/tinycomputer-bus/src/agent/agent_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,18 +281,40 @@ fn waiting_and_continuing_have_forgiving_defaults() {
assert_eq!(resume.id.to_string(), "t-1");
assert_eq!(resume.inputs["date of birth"], "1990-04-02");
assert_eq!(resume.approve, None);
assert_eq!(resume.host_context, None);
assert!(
serde_json::to_value(&resume)
.unwrap()
.get("host_context")
.is_none()
);

let private: ContinueTaskRequest = serde_json::from_value(json!({
"id": "t-2",
"host_context": "opaque-context",
"fact_handles": {
"email": {"handle": "opaque-email", "mask": "‹email›", "kind": "asked_input"}
}
}))
.unwrap();
assert_eq!(private.fact_handles["email"].handle, "opaque-email");
assert_eq!(
private
.host_context
.as_ref()
.map(super::HostContext::as_str),
Some("opaque-context")
);
let wire = serde_json::to_value(private).unwrap();
assert_eq!(wire["fact_handles"]["email"]["mask"], "‹email›");
assert_eq!(wire["inputs"], json!({}));
assert_eq!(wire["host_context"], "opaque-context");
}

#[test]
fn host_context_debug_output_hides_the_opaque_value() {
let context = super::HostContext::new("secret-capability");
assert!(!format!("{context:?}").contains("secret-capability"));
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions crates/tinycomputer-bus/src/agent/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ mod types;

pub use types::{
AgentError, AgentResponse, AwaitTaskRequest, Capabilities, ContinueTaskRequest, Example,
InputField, InputKind, LanguageModelConfiguration, LanguageModelProvider, MemberDoc,
ModelUsage, PaymentMode, PlanTaskRequest, Rescue, RescueOutcome, SecretHandle,
HostContext, InputField, InputKind, LanguageModelConfiguration, LanguageModelProvider,
MemberDoc, ModelUsage, PaymentMode, PlanTaskRequest, Rescue, RescueOutcome, SecretHandle,
StartTaskRequest, StepView, SurfaceAvailability, SurfaceKind, TaskBudget, TaskConstraints,
TaskId, TaskOutput, TaskPlan, TaskRef, TaskReport, TaskReportRequest, TaskStatus, TaskUsage,
TaskView,
Expand Down
2 changes: 1 addition & 1 deletion crates/tinycomputer-bus/src/agent/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub use models::{LanguageModelConfiguration, LanguageModelProvider};
pub use reply::{AgentError, AgentResponse};
pub use report::{Rescue, RescueOutcome, TaskReport};
pub use request::{
AwaitTaskRequest, ContinueTaskRequest, PaymentMode, PlanTaskRequest, SecretHandle,
AwaitTaskRequest, ContinueTaskRequest, HostContext, PaymentMode, PlanTaskRequest, SecretHandle,
StartTaskRequest, SurfaceKind, TaskBudget, TaskConstraints, TaskId, TaskOutput, TaskPlan,
TaskRef, TaskReportRequest,
};
Expand Down
31 changes: 31 additions & 0 deletions crates/tinycomputer-bus/src/agent/types/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,33 @@ impl std::fmt::Debug for SecretHandle {
}
}

/// Opaque, host-issued context carried from a task continuation to a
/// `ConsequenceHost` review. The module must relay it unchanged and never
/// treat it as authorization. Debug output deliberately hides the value.
#[derive(Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
#[serde(transparent)]
pub struct HostContext(String);

impl HostContext {
/// Wraps a host-issued opaque context value.
#[must_use]
pub fn new(value: impl Into<String>) -> Self {
Self(value.into())
}

/// Returns the opaque value for host-side lookup.
#[must_use]
pub fn as_str(&self) -> &str {
&self.0
}
}

impl std::fmt::Debug for HostContext {
fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
formatter.write_str("HostContext([opaque])")
}
}

/// What a finished task returns, beyond its raw records.
///
/// The result is always a JSON object. `schema` is a JSON Schema it must
Expand Down Expand Up @@ -251,6 +278,10 @@ pub struct ContinueTaskRequest {
/// The decision on a `needs_approval` pause, or `true` to go past a
/// non-payment `checkpoint`.
pub approve: Option<bool>,
/// Opaque host-issued context for reviewing this continuation. The module
/// carries it to `ConsequenceHost` without interpreting or authorizing it.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub host_context: Option<HostContext>,
Comment thread
senamakel marked this conversation as resolved.
Resolved
/// A free-text answer, for a pause that asked a question — or, for
/// `needs_human`, `"done"` once the person has finished.
pub answer: Option<String>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,29 @@ fn the_interface_is_its_own_not_the_desktop_or_site_memory_one() {
#[test]
fn a_review_request_keeps_its_wire_form() {
let request: ReviewActionRequest = serde_json::from_value(serde_json::json!({
"task": "t1", "action": "pay now", "target": "Pay", "kind": "payment"
"task": "t1", "action": "pay now", "target": "Pay", "kind": "payment",
"host_context": "opaque-context"
}))
.unwrap();
assert_eq!(request.kind, ConsequenceKind::Payment);
assert_eq!(
request
.host_context
.as_ref()
.map(crate::agent::HostContext::as_str),
Some("opaque-context")
);
let json = serde_json::to_value(&request).unwrap();
assert_eq!(json["kind"], "payment");
assert_eq!(json["host_context"], "opaque-context");
let irreversible = serde_json::to_value(ConsequenceKind::Irreversible).unwrap();
assert_eq!(irreversible, "irreversible");

let legacy: ReviewActionRequest = serde_json::from_value(serde_json::json!({
"task": "t2", "action": "send", "target": "Send", "kind": "irreversible"
}))
.unwrap();
assert_eq!(legacy.host_context, None);
}

#[test]
Expand Down
6 changes: 6 additions & 0 deletions crates/tinycomputer-bus/src/consequence_host/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

use serde::{Deserialize, Serialize};

use crate::agent::HostContext;

/// The interface the host serves consequence review on.
pub const INTERFACE: &str = "ai.tinyhumans.tinycomputer.ConsequenceHost";

Expand Down Expand Up @@ -58,6 +60,10 @@ pub struct ReviewActionRequest {
pub target: String,
/// What the module classified the action as.
pub kind: ConsequenceKind,
/// Opaque host-issued context from the `ContinueTask` request. The module
/// relays this value unchanged and grants it no authority.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub host_context: Option<HostContext>,
}

/// The reply to `Review`.
Expand Down
4 changes: 2 additions & 2 deletions crates/tinycomputer-bus/src/version/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//! release workflow bumps, which tracks the shipped artifact.

/// The wire contract version this crate defines.
Comment thread
senamakel marked this conversation as resolved.
Resolved
pub const CONTRACT_VERSION: (u32, u32) = (2, 26);
pub const CONTRACT_VERSION: (u32, u32) = (2, 27);

/// Returns whether a host holding [`CONTRACT_VERSION`] can bind to a module
/// reporting `module`.
Expand All @@ -22,7 +22,7 @@ pub const CONTRACT_VERSION: (u32, u32) = (2, 26);
/// ```
/// # use tinycomputer_bus::{is_compatible, CONTRACT_VERSION};
/// assert!(is_compatible(CONTRACT_VERSION));
/// assert!(is_compatible((2, 26)));
/// assert!(is_compatible((2, 27)));
/// assert!(!is_compatible((2, 11)));
/// assert!(!is_compatible((1, 8)));
/// ```
Expand Down
7 changes: 5 additions & 2 deletions crates/tinycomputer-bus/src/version/version_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use super::{CONTRACT_VERSION, binds, is_compatible};

#[test]
fn the_shipped_contract_version_is_pinned() {
assert_eq!(CONTRACT_VERSION, (2, 26));
assert_eq!(CONTRACT_VERSION, (2, 27));
}

#[test]
Expand All @@ -16,7 +16,7 @@ fn the_contract_binds_to_itself() {

#[test]
fn a_newer_minor_on_the_module_side_binds() {
assert!(is_compatible((2, 26)));
assert!(is_compatible((2, 27)));
assert!(is_compatible((2, 97)));
// 2.24 adds same-task flow-to-planner handoff to StartTask.
// 2.22 adds optional host-held secret handles to StartTask and RunFlow.
Expand All @@ -42,6 +42,9 @@ fn a_newer_minor_on_the_module_side_binds() {
// 2.20 adds SessionOptions identity fields.
// 2.25 adds BrowserEgressHost.
// 2.26 adds TraceSinkHost, so a 2.25 module lacks that callback.
// 2.27 relays opaque host context to ConsequenceHost reviews. A 2.26
// module would drop that context, so a host requiring it cannot bind.
assert!(!is_compatible((2, 26)));
assert!(!is_compatible((2, 25)));
assert!(!is_compatible((2, 24)));
assert!(!is_compatible((2, 23)));
Expand Down
4 changes: 2 additions & 2 deletions crates/tinycomputer-engine/src/task/describe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
//! The schemas here are written by hand, so each field of a request type
//! must be added here when it is added to the contract, save the host's
//! own settings no model is offered (a task's browser binary and profile);
//! `task_tests/describe_tests.rs` checks the `StartTask` and `PlanTask`
//! schemas name every other field their types serialize.
//! `task_tests/describe_tests.rs` checks the request schemas name their
//! model-settable fields; host-only context is deliberately omitted.

use serde_json::{Value, json};
use tinycomputer_bus::agent::names::{CONFIDENTIAL, methods};
Expand Down
29 changes: 28 additions & 1 deletion crates/tinycomputer-engine/src/task/task_tests/describe_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ fn continue_with_handle(
id,
approve: Some(true),
answer: Some(String::new()),
host_context: Some(tinycomputer_bus::agent::HostContext::new("opaque-context")),
fact_handles: std::collections::BTreeMap::from([(
"email".to_owned(),
tinycomputer_bus::agent::SecretHandle {
Expand Down Expand Up @@ -256,7 +257,20 @@ async fn describe_schemas_name_every_request_field() {

let plan = serde_json::to_value(tinycomputer_bus::agent::PlanTaskRequest::default()).unwrap();
assert_eq!(documented(&schema("PlanTask")), fields(&plan));
}

#[tokio::test]
async fn describe_schemas_name_continuation_request_fields() {
let (tasks, _) = controller(Vec::new());
let described = capabilities(Vec::new(), Some(&jev()), &tasks);
let schema = |name: &str| {
described
.members
.iter()
.find(|member| member.name == name)
.map(|member| member.input.clone())
.expect("the member is documented")
};
let id = tinycomputer_bus::agent::TaskId::new("t-1");
let others = [
(
Expand All @@ -282,10 +296,23 @@ async fn describe_schemas_name_every_request_field() {
for (member, request) in others {
assert_eq!(
documented(&schema(member)),
fields(&request.unwrap()),
if member == "ContinueTask" {
fields(&request.unwrap())
.into_iter()
.filter(|field| field != "host_context")
.collect()
} else {
fields(&request.unwrap())
},
"{member}"
);
}
assert!(
schema("ContinueTask")["properties"]
.get("host_context")
.is_none(),
"host context is injected by the trusted host, not exposed to agents"
);
// Every member with a request object is compared above; the rest take
// no argument.
for member in &described.members {
Expand Down
8 changes: 8 additions & 0 deletions crates/tinycomputer/src/tinybus_module/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ TinyBus treats initial and replacement module configuration as sensitive
host-control traffic. An unreadable configuration fails before replacing the
served object rather than falling back to defaults.

Setting `consequence_host` to an object with the unique `destination` supplied
by `ModuleHost::prepare_host_callbacks` enables confidential consequence
reviews. When `ContinueTask` approves a pending action for host review, the
module declines it if the configured callback is absent or cannot answer. A
declined approval, an unanswered pause, or a continuation with no pending
action does not fail solely because this callback is absent. Without host
context, the legacy well-known host interface remains available.

## The manifest

`tinybus_module::module_export_optional_static!` emits (C exports by default; `linked_module()` under `static-link`) the descriptor, embedded manifest, and
Expand Down
38 changes: 38 additions & 0 deletions crates/tinycomputer/src/tinybus_module/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,44 @@ pub(crate) fn trace_sink_destination(
}
}

/// Whether the host prepared a confidential consequence-review callback.
pub(crate) fn consequence_host_destination(
config: &serde_json::Value,
) -> Result<Option<tinybus::BusName>> {
match config
.as_object()
.and_then(|object| object.get("consequence_host"))
Comment thread
senamakel marked this conversation as resolved.
Resolved
Comment thread
senamakel marked this conversation as resolved.
Resolved
{
None | Some(serde_json::Value::Bool(false)) => Ok(None),
Some(serde_json::Value::Object(options)) if options.len() == 1 => {
let destination = options
.get("destination")
.and_then(serde_json::Value::as_str)
.ok_or(crate::Error::ConfigFieldType {
field: "consequence_host.destination",
expected: "the unique name of the host callback prepared for this module",
})?;
tinybus::BusName::new(destination.to_owned())
.map_err(|_| crate::Error::ConfigFieldType {
field: "consequence_host.destination",
expected: "the unique name of the host callback prepared for this module",
})
.and_then(|name| {
name.is_unique()
.then_some(Some(name))
.ok_or(crate::Error::ConfigFieldType {
field: "consequence_host.destination",
expected: "the unique name of the host callback prepared for this module",
})
})
}
Some(_) => Err(crate::Error::ConfigFieldType {
field: "consequence_host",
expected: "false or an object containing only the host callback `destination`",
}),
}
}

/// The `cursor` configuration: the agent's one on-screen cursor, shared by
/// the desktop and every task's browser. Either a pace name, or an object
/// with an optional `pace` and an optional `overlay` path to the
Expand Down
Loading
Loading