Make Codex and Claude Code subscriptions go further: a local model router that gives routine agent work to economical models and keeps your strongest model for the hard parts.
Rust ai-agentsai-gatewayclaude-codecodexcoding-agentcost-optimizationdeepseekllm-gatewayllm-routerlocal-firstmodel-routingrusttask-routingtauri
fix(cli): submit Worker requests without local receipts (#116)
澄潭e160b165b800
diff --git a/contracts/cli/contract-set.v1.json b/contracts/cli/contract-set.v1.jsonindex b0766429..64257ff6 100644--- a/contracts/cli/contract-set.v1.json+++ b/contracts/cli/contract-set.v1.json@@ -1,10 +1,10 @@{- "descriptor_digest": "sha256:1bdd37be3354af88208d5c9f91945f23b392c2bce3eb8ceb5677fa945126d4c5",+ "descriptor_digest": "sha256:3ae32fc9b7da19b9d8b23ffefd8a25bc221dc86adc3bdbaca761f176928508b9","files": {"agent-check-request.v1.schema.json": "sha256:fbd9e9b19282a5ed8c3e30b5ae16538bc01318a70e4bb7c7a55e8e0472553feb","agent-launch-descriptor-request.v1.schema.json": "sha256:28f2f9d2d7f9a1618bea0f13383002429bc9e0ff56166cbee86958a245d0fd48","agent-plan-catalog-query.v2.schema.json": "sha256:a597b26eac530352f522a05c29a7c8c3a0ee2b553d69d1d911c2b0a44033338c",- "coverage-manifest.v1.json": "sha256:0b5c8f1c46f0084f0a813675ce04b80a478ab956968b7faef717054d098affcc",+ "coverage-manifest.v1.json": "sha256:5146f51768c3a0aaf248834ad6cdc227090037b58d8e0540787d838357ae6fb9","delegation-cancel-request.v1.schema.json": "sha256:0822c53fc16acfcd618fbef66410939f33f634313389a6df4705f414a468b878","delegation-continue-request.v1.schema.json": "sha256:da2f81607f37d154a0fa698a107b37d4b0e9d5a03693dcbcc41e0b7e65db5b93","delegation-get-request.v1.schema.json": "sha256:85b29839c1c508018ebe40e4b2bb5c1dce7c3a87c27efa30b196b2d1b6658471",@@ -16,14 +16,14 @@"local-control-hello.v2.schema.json": "sha256:32fbce882152a886b79bd139d3b4e459b48d94e0634e56ccb189b2c9971ad772","local-control.v2.schema.json": "sha256:4b654de90cd6e333b3953379e5b2e1c5125f1dcbe307b7c7c73f12bb2032d18c","machine-envelope.v2.schema.json": "sha256:23e019a3d024ae302a44105caff4ec95d3fb409a29f936dea1360e543ae6abd6",- "manifest.v1.json": "sha256:58786a9e169957e4ff2d651698d2671919aef87fea9a57e79954ce268afd15e1",+ "manifest.v1.json": "sha256:b4061beb8ed0793b3933dd26b56b3ee4649f15fc7b5267bb3a0693c2d2289c97","operation-cancel-request.v1.schema.json": "sha256:0071cbcf27de3bfb7f6644478fe2b73bb5387ebe33db93629ff5672959e8495f","operation-lookup.v1.schema.json": "sha256:0fbaaa15b0e75b4186979bdd856bed0485d55a4bd33a33f3caf3bd92e01a7850","plan-content-change.v2.schema.json": "sha256:d07d6595109e50ffc0e253b8cfad578632ebc300e014d45e33f02c446b9d42de","plan-draft-change.v1.schema.json": "sha256:46366339b9a3689ea0195c641ca9b16820c678641950dd8357db526a07d7bf91","plan-editor.v2.schema.json": "sha256:9ce9efd5d8117a9ddb6c1b46d16a9b7eb6ec11e4672b5dac8d3893323dd39ffa","plan-lifecycle-change.v1.schema.json": "sha256:a53203683920280574c0ed8c8f888159c10d5df8949b89af67638116ec374a62",- "planned-manifest.v1.json": "sha256:344e9e13c6472d64fb029a749cc794eb8620ee3ebf1a70f002c071b963ed072f",+ "planned-manifest.v1.json": "sha256:23b55550d74dd743fbaf18052ea818cfac1e8f3ed63af0db300f62f3b4c97977","publication-checkpoint-change.v1.schema.json": "sha256:4d5a709ba41f529318d5e5c1b1399a2e84c5c51f49527edf927e5824412a795d","session-list-query.v1.schema.json": "sha256:1f71a89fc019b59c3499708c0760b694b8cb8532028b56d98702cd3b2721cd44","session-lookup.v1.schema.json": "sha256:0c9e0ea31bdde7f720a9a17e8dc175902a20b3fb92abc21ce4bdae9fc3d97587",diff --git a/contracts/cli/coverage-manifest.v1.json b/contracts/cli/coverage-manifest.v1.jsonindex 5fcc7113..12341a6c 100644--- a/contracts/cli/coverage-manifest.v1.json+++ b/contracts/cli/coverage-manifest.v1.json@@ -1219,7 +1219,7 @@}}],- "descriptor_digest": "sha256:1bdd37be3354af88208d5c9f91945f23b392c2bce3eb8ceb5677fa945126d4c5",+ "descriptor_digest": "sha256:3ae32fc9b7da19b9d8b23ffefd8a25bc221dc86adc3bdbaca761f176928508b9","schema_version": {"major": 1,"minor": 0diff --git a/contracts/cli/manifest.v1.json b/contracts/cli/manifest.v1.jsonindex a1f585dc..3ae4a4be 100644--- a/contracts/cli/manifest.v1.json+++ b/contracts/cli/manifest.v1.json@@ -5,7 +5,7 @@},"product_contract_revision": "487a807c8dc25cfb24e8b097882cd3bb9716a009","proposal_map_revision": "ab4da93cc49c6ec56a01e046230411ff1ca82300",- "descriptor_digest": "sha256:1bdd37be3354af88208d5c9f91945f23b392c2bce3eb8ceb5677fa945126d4c5",+ "descriptor_digest": "sha256:3ae32fc9b7da19b9d8b23ffefd8a25bc221dc86adc3bdbaca761f176928508b9","visibility": "release","commands": [{@@ -1379,7 +1379,7 @@"help": {"purpose": "Submit one local Worker task with an explicit cwd and run-scoped permission policy.","usage": "hiroute worker exec --plan <ID> --cwd <PATH> [--title <TITLE>] [--permission-policy <approve-all|approve-reads|deny-all>] [--run-timeout <1..86400>] [--no-wait | --wait-timeout <1..30>] [--submission-key <KEY>] (-- <TEXT> | --file <PATH> | < stdin)",- "arguments_and_options": "Plan, cwd, and exactly one text source are required. Permission policy defaults to approve-all; approve-reads and deny-all are explicit run restrictions and fail unavailable unless the exact Harness mapping proves them. cwd is scheduling context, not directory authorization. A private receipt is saved before transmission; uncertain delivery keeps the same submission key.",+ "arguments_and_options": "Plan, cwd, and exactly one text source are required. Permission policy defaults to approve-all; approve-reads and deny-all are explicit run restrictions and fail unavailable unless the exact Harness mapping proves them. cwd is scheduling context, not directory authorization. Submits directly to the daemon without a local receipt. Choose a unique --submission-key before sending; after uncertain delivery, query or retry with that original key and the identical request.","effects": "Durably admits one bounded Worker run after current Plan eligibility, exact Plan, canonical cwd, idempotency, and resource checks.","network_and_model_use": "The selected Worker may send model traffic only through its run-bound numeric-loopback Gateway route; native tools follow the run-scoped permission policy.","automation": "The command durably admits a bounded Worker run; that Worker may make model requests only through its exact run-bound loopback Gateway route.",diff --git a/contracts/cli/planned-manifest.v1.json b/contracts/cli/planned-manifest.v1.jsonindex de5caf1e..f54dbb0f 100644--- a/contracts/cli/planned-manifest.v1.json+++ b/contracts/cli/planned-manifest.v1.json@@ -5,7 +5,7 @@},"product_contract_revision": "487a807c8dc25cfb24e8b097882cd3bb9716a009","proposal_map_revision": "ab4da93cc49c6ec56a01e046230411ff1ca82300",- "descriptor_digest": "sha256:1bdd37be3354af88208d5c9f91945f23b392c2bce3eb8ceb5677fa945126d4c5",+ "descriptor_digest": "sha256:3ae32fc9b7da19b9d8b23ffefd8a25bc221dc86adc3bdbaca761f176928508b9","visibility": "planned","commands": [{@@ -2196,7 +2196,7 @@"help": {"purpose": "Submit one local Worker task with an explicit cwd and run-scoped permission policy.","usage": "hiroute worker exec --plan <ID> --cwd <PATH> [--title <TITLE>] [--permission-policy <approve-all|approve-reads|deny-all>] [--run-timeout <1..86400>] [--no-wait | --wait-timeout <1..30>] [--submission-key <KEY>] (-- <TEXT> | --file <PATH> | < stdin)",- "arguments_and_options": "Plan, cwd, and exactly one text source are required. Permission policy defaults to approve-all; approve-reads and deny-all are explicit run restrictions and fail unavailable unless the exact Harness mapping proves them. cwd is scheduling context, not directory authorization. A private receipt is saved before transmission; uncertain delivery keeps the same submission key.",+ "arguments_and_options": "Plan, cwd, and exactly one text source are required. Permission policy defaults to approve-all; approve-reads and deny-all are explicit run restrictions and fail unavailable unless the exact Harness mapping proves them. cwd is scheduling context, not directory authorization. Submits directly to the daemon without a local receipt. Choose a unique --submission-key before sending; after uncertain delivery, query or retry with that original key and the identical request.","effects": "Durably admits one bounded Worker run after current Plan eligibility, exact Plan, canonical cwd, idempotency, and resource checks.","network_and_model_use": "The selected Worker may send model traffic only through its run-bound numeric-loopback Gateway route; native tools follow the run-scoped permission policy.","automation": "The command durably admits a bounded Worker run; that Worker may make model requests only through its exact run-bound loopback Gateway route.",diff --git a/contracts/compatibility-support.v1.json b/contracts/compatibility-support.v1.jsonindex b74fbc24..5deed43d 100644--- a/contracts/compatibility-support.v1.json+++ b/contracts/compatibility-support.v1.json@@ -389,12 +389,10 @@"hiroute.worker-plans-request/v1","hiroute.worker-read-data/v1","hiroute.worker-read-request/v1",- "hiroute.worker-receipt/v1","hiroute.worker-residual-confirm-request/v1","hiroute.worker-result-request/v1","hiroute.worker-settings/v1","hiroute.worker-status-request/v1",- "hiroute.worker-submission-receipt/v1","hiroute.worker-wait-request/v1"],"subjects": [@@ -1391,6 +1389,21 @@"crates/domain/src/observation/execution_tests.rs","crates/observation/src/store/tests/store_flow.rs"]+ },+ {+ "contract": "hiroute.managed-collaboration-skill/v2",+ "field": "released v0.3.1 worker-instance-explicit-v1 and worker-instance-default-v1 installed Skill bytes",+ "mode": "frozen_fixture",+ "owner": "agent-collaboration-settings",+ "reason": "Freeze public stable source 13856abd873da5b4373d39322493b4cc105c4867 templates as upgrade input. Install through the existing Preview/Apply Operation and owned file writer, then current Configure replaces the exact owned generation without changing model settings or rewriting original Operation bytes. Startup alone does not refresh an installed Skill; borrowed or modified files keep the existing conflict boundary.",+ "removal_condition": "Retire only when v0.3.1 installed Skill upgrade support ends through an explicit product decision with replacement ownership and recovery evidence; never regenerate the old bytes from current templates.",+ "allowed_paths": [+ "crates/daemon/tests/fixtures/collaboration-skill-v0.3.1/explicit.md",+ "crates/daemon/tests/fixtures/collaboration-skill-v0.3.1/default.md",+ "crates/daemon/tests/fixtures/collaboration-skill-v0.3.1/README.md",+ "crates/daemon/src/control/runtime/settings_entry_tests.rs",+ "crates/daemon/src/control/runtime/settings_entry_collaboration_tests.rs"+ ]}]}diff --git a/crates/application-api/src/protocol.rs b/crates/application-api/src/protocol.rsindex 7f7fc446..4fbfc552 100644--- a/crates/application-api/src/protocol.rs+++ b/crates/application-api/src/protocol.rs@@ -1123,7 +1123,7 @@ pub(crate) fn command_arguments(command_id: &str) -> String {"worker.dependencies.select" => "Same-UID local management only. --request-stdin reads one strict JSON object with harness (codex_cli, claude_code, qoder_cli, pi, or deepseek_harness), absolute cli_path, and expected_selection_revision copied from the matching selection_revisions entry returned by worker dependencies discover --output json. codex_cli and claude_code require absolute adapter_path and accept optional absolute node_path. pi requires absolute node_path and forbids adapter_path. qoder_cli and deepseek_harness accept only cli_path and forbid adapter_path and node_path. All paths and the revision are validated again before an atomic selection update; the command never installs software or accepts an Apply capability.".into(),"worker.plans" => "Lists every currently published and delegation-enabled Worker Plan in this daemon instance; no main-Agent selector or allowlist participates.".into(),"worker.list" => "Pages the daemon instance's durable tasks newest-first. --title is normalized exact matching; the signed opaque cursor is bound to that filter. Default 50, maximum 200, and no total count.".into(),- "worker.exec" => "Plan, cwd, and exactly one text source are required. Permission policy defaults to approve-all; approve-reads and deny-all are explicit run restrictions and fail unavailable unless the exact Harness mapping proves them. cwd is scheduling context, not directory authorization. A private receipt is saved before transmission; uncertain delivery keeps the same submission key.".into(),+ "worker.exec" => "Plan, cwd, and exactly one text source are required. Permission policy defaults to approve-all; approve-reads and deny-all are explicit run restrictions and fail unavailable unless the exact Harness mapping proves them. cwd is scheduling context, not directory authorization. Submits directly to the daemon without a local receipt. Choose a unique --submission-key before sending; after uncertain delivery, query or retry with that original key and the identical request.".into(),"worker.status" => "Select exactly a run, a task (and optional historical run), or an original submission key plus start|continue. The daemon instance is the task namespace; no caller, Agent, grant, permit, or workspace-root identity is accepted.".into(),"worker.read" => "Reads a bounded best-effort public assistant-message progress window. It is not a complete log or completion proof; cursors are opaque, signed and run-bound.".into(),"worker.wait" => "Wait is bounded to 1..30 seconds and never cancels the run. A timeout is a pending observation with a reusable run locator.".into(),diff --git a/crates/cli/src/worker.rs b/crates/cli/src/worker.rsindex 8ed2b5ba..f9f3178e 100644--- a/crates/cli/src/worker.rs+++ b/crates/cli/src/worker.rs@@ -7,21 +7,18 @@ use hiroute_application_api::{WorkerContinueRequestV1, WorkerExecRequestV1, WorkerListRequestV1, WorkerPlansRequestV1,WorkerResultRequestV1, WorkerWaitRequestV1,};-use hiroute_client_core::{ClientFailure, FailureCode, SubmissionState};-use serde_json::json;+use hiroute_client_core::{ClientFailure, FailureCode};use crate::args::{Globals, OutputMode};use crate::{CliExecution, LocalControlClient};mod input;-mod receipt;mod render;use input::{parse_cancel, parse_dependencies_discover, parse_dependency_selection, parse_list, parse_read,parse_residual_confirm, parse_result, parse_status, parse_submission, parse_wait,};-use receipt::{ReceiptError, SubmissionReceipt};use render::{CommandData, command_data, erase, render_cancel, render_erased, render_result, render_status,render_transport, render_wait, render_worker_data, uncertain_submission,@@ -224,55 +221,9 @@ fn exec(Some(request_id),);}- let selectors = json!({"plan_id":request.plan_id,"cwd":request.cwd});- let receipt =- match SubmissionReceipt::prepare("exec", &request.submission_key, selectors, &request) {- Ok(receipt) => receipt,- Err(ReceiptError::Conflict) => {- return failure(- ErrorCode::RevisionConflict,- globals.output,- Some(request_id),- );- }- Err(ReceiptError::Unavailable) => {- return failure(- ErrorCode::CapabilityUnavailable,- globals.output,- Some(request_id),- );- }- };- let response = call(client.shared_client().worker_exec(&request_id, &request));- let response = match response {- Ok(response) => {- let locator = response- .data- .as_ref()- .map(|accepted| (accepted.task_id.as_str(), accepted.run_id.as_str()));- let _ = receipt.record(- if response.status == MachineStatus::Succeeded- || response.status == MachineStatus::Accepted- {- "accepted"- } else {- "rejected"- },- locator.map(|(task, _)| task),- locator.map(|(_, run)| run),- );- response- }+ let response = match call(client.shared_client().worker_exec(&request_id, &request)) {+ Ok(response) => response,Err(error) => {- let _ = receipt.record(- if error.submission == SubmissionState::MayHaveReachedServer {- "delivery_uncertain"- } else {- "not_sent"- },- None,- None,- );return uncertain_submission("exec",&request.submission_key,@@ -340,68 +291,13 @@ fn continue_task(Some(request_id),);}- let selectors = json!({- "task_id":request.task_id,- "expected_latest_run_id":request.expected_latest_run_id,- "cwd":request.cwd,- });- let receipt = match SubmissionReceipt::prepare(- "continue",- &request.submission_key,- selectors,- &request,- ) {- Ok(receipt) => receipt,- Err(ReceiptError::Conflict) => {- return failure(- ErrorCode::RevisionConflict,- globals.output,- Some(request_id),- );- }- Err(ReceiptError::Unavailable) => {- return failure(- ErrorCode::CapabilityUnavailable,- globals.output,- Some(request_id),- );- }- };- let response = call(+ let response = match call(client.shared_client().worker_continue(&request_id, &request),- );- let response = match response {- Ok(response) => {- let locator = response- .data- .as_ref()- .map(|accepted| (accepted.task_id.as_str(), accepted.run_id.as_str()));- let _ = receipt.record(- if matches!(- response.status,- MachineStatus::Succeeded | MachineStatus::Accepted- ) {- "accepted"- } else {- "rejected"- },- locator.map(|(task, _)| task),- locator.map(|(_, run)| run),- );- response- }+ ) {+ Ok(response) => response,Err(error) => {- let _ = receipt.record(- if error.submission == SubmissionState::MayHaveReachedServer {- "delivery_uncertain"- } else {- "not_sent"- },- None,- None,- );return uncertain_submission("continue",&request.submission_key,diff --git a/crates/cli/src/worker/receipt.rs b/crates/cli/src/worker/receipt.rsdeleted file mode 100644index 7309649c..00000000--- a/crates/cli/src/worker/receipt.rs+++ /dev/null@@ -1,304 +0,0 @@-use std::io::Write;-use std::path::{Path, PathBuf};-use std::time::{SystemTime, UNIX_EPOCH};--use hiroute_application_api::CanonicalDigest;-use serde::{Deserialize, Serialize};-use serde_json::Value;--#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]-#[serde(deny_unknown_fields)]-struct SubmissionReceiptRecord {- schema: String,- operation: String,- submission_key: String,- selectors: Value,- intent_digest: CanonicalDigest,- prepared_at_ms: u64,- updated_at_ms: u64,- state: String,- #[serde(default, skip_serializing_if = "Option::is_none")]- task_id: Option<String>,- #[serde(default, skip_serializing_if = "Option::is_none")]- run_id: Option<String>,-}--pub(super) struct SubmissionReceipt {- path: PathBuf,- record: SubmissionReceiptRecord,-}--#[derive(Clone, Copy, Debug, Eq, PartialEq)]-pub(super) enum ReceiptError {- Conflict,- Unavailable,-}--impl SubmissionReceipt {- pub(super) fn prepare(- operation: &str,- key: &str,- selectors: Value,- intent: &impl Serialize,- ) -> Result<Self, ReceiptError> {- let root = receipt_root().ok_or(ReceiptError::Unavailable)?;- Self::prepare_in(&root, operation, key, selectors, intent)- }-- fn prepare_in(- root: &Path,- operation: &str,- key: &str,- selectors: Value,- intent: &impl Serialize,- ) -> Result<Self, ReceiptError> {- prepare_private_directory(root)?;- let name = CanonicalDigest::of(&("hiroute.worker-receipt/v1", operation, key))- .map_err(|_| ReceiptError::Unavailable)?;- let path = root.join(format!(- "{}.json",- name.as_str()- .strip_prefix("sha256:")- .unwrap_or(name.as_str())- ));- let now = now_ms()?;- let record = SubmissionReceiptRecord {- schema: "hiroute.worker-submission-receipt/v1".into(),- operation: operation.into(),- submission_key: key.into(),- selectors,- intent_digest: CanonicalDigest::of(intent).map_err(|_| ReceiptError::Unavailable)?,- prepared_at_ms: now,- updated_at_ms: now,- state: "prepared".into(),- task_id: None,- run_id: None,- };- if path.exists() {- let existing = read_receipt(&path)?;- if !same_submission(&existing, &record) {- return Err(ReceiptError::Conflict);- }- return Ok(Self {- path,- record: existing,- });- }- match write_receipt(&path, &record, false) {- Ok(()) => Ok(Self { path, record }),- Err(ReceiptError::Conflict) => {- let existing = read_receipt(&path)?;- if same_submission(&existing, &record) {- Ok(Self {- path,- record: existing,- })- } else {- Err(ReceiptError::Conflict)- }- }- Err(error) => Err(error),- }- }-- pub(super) fn record(- mut self,- state: &str,- task_id: Option<&str>,- run_id: Option<&str>,- ) -> Result<(), ReceiptError> {- self.record.updated_at_ms = now_ms()?;- self.record.state = state.into();- self.record.task_id = task_id.map(str::to_owned);- self.record.run_id = run_id.map(str::to_owned);- write_receipt(&self.path, &self.record, true)- }-}--fn same_submission(left: &SubmissionReceiptRecord, right: &SubmissionReceiptRecord) -> bool {- left.operation == right.operation- && left.submission_key == right.submission_key- && left.selectors == right.selectors- && left.intent_digest == right.intent_digest-}--fn receipt_root() -> Option<PathBuf> {- if let Some(path) = std::env::var_os("HIROUTE_WORKER_RECEIPT_DIR") {- return Some(PathBuf::from(path));- }- #[cfg(target_os = "macos")]- {- std::env::var_os("HOME")- .map(PathBuf::from)- .map(|home| home.join("Library/Application Support/HiRoute/worker-receipts"))- }- #[cfg(target_os = "windows")]- {- return std::env::var_os("LOCALAPPDATA")- .map(PathBuf::from)- .map(|root| root.join("HiRoute/worker-receipts"));- }- #[cfg(all(unix, not(target_os = "macos")))]- {- std::env::var_os("XDG_DATA_HOME")- .map(PathBuf::from)- .or_else(|| {- std::env::var_os("HOME")- .map(PathBuf::from)- .map(|home| home.join(".local/share"))- })- .map(|root| root.join("hiroute/worker-receipts"))- }-}--fn prepare_private_directory(path: &Path) -> Result<(), ReceiptError> {- let mut builder = std::fs::DirBuilder::new();- builder.recursive(true);- #[cfg(unix)]- {- use std::os::unix::fs::DirBuilderExt;- builder.mode(0o700);- }- builder- .create(path)- .map_err(|_| ReceiptError::Unavailable)?;- #[cfg(unix)]- {- let metadata = std::fs::symlink_metadata(path).map_err(|_| ReceiptError::Unavailable)?;- if !metadata.is_dir() || metadata.file_type().is_symlink() {- return Err(ReceiptError::Unavailable);- }- }- Ok(())-}--fn read_receipt(path: &Path) -> Result<SubmissionReceiptRecord, ReceiptError> {- validate_private_file(path)?;- let bytes = std::fs::read(path).map_err(|_| ReceiptError::Unavailable)?;- if bytes.len() > 16 * 1024 {- return Err(ReceiptError::Unavailable);- }- serde_json::from_slice(&bytes).map_err(|_| ReceiptError::Unavailable)-}--fn write_receipt(- path: &Path,- record: &SubmissionReceiptRecord,- replace: bool,-) -> Result<(), ReceiptError> {- let parent = path.parent().ok_or(ReceiptError::Unavailable)?;- let temporary = parent.join(format!(".receipt-{}-{}", std::process::id(), now_ms()?));- let mut options = std::fs::OpenOptions::new();- options.write(true).create_new(true);- #[cfg(unix)]- {- use std::os::unix::fs::OpenOptionsExt;- options.mode(0o600);- }- let result = (|| {- let mut file = options- .open(&temporary)- .map_err(|_| ReceiptError::Unavailable)?;- serde_json::to_writer(&mut file, record).map_err(|_| ReceiptError::Unavailable)?;- file.write_all(b"\n")- .and_then(|_| file.sync_all())- .map_err(|_| ReceiptError::Unavailable)?;- if replace {- replace_file(&temporary, path)?;- } else {- match std::fs::hard_link(&temporary, path) {- Ok(()) => {- std::fs::remove_file(&temporary).map_err(|_| ReceiptError::Unavailable)?;- }- Err(_) if path.exists() => return Err(ReceiptError::Conflict),- Err(_) => return Err(ReceiptError::Unavailable),- }- }- sync_parent(parent)?;- validate_private_file(path)- })();- if result.is_err() {- let _ = std::fs::remove_file(&temporary);- }- result-}--fn replace_file(temporary: &Path, path: &Path) -> Result<(), ReceiptError> {- match std::fs::rename(temporary, path) {- Ok(()) => Ok(()),- // Windows does not replace an existing destination with rename. Keep the already- // durable prepared receipt rather than introduce a remove/rename visibility gap.- Err(_) if path.exists() => {- std::fs::remove_file(temporary).map_err(|_| ReceiptError::Unavailable)- }- Err(_) => Err(ReceiptError::Unavailable),- }-}--fn sync_parent(path: &Path) -> Result<(), ReceiptError> {- #[cfg(unix)]- {- std::fs::File::open(path)- .and_then(|directory| directory.sync_all())- .map_err(|_| ReceiptError::Unavailable)?;- }- Ok(())-}--fn validate_private_file(path: &Path) -> Result<(), ReceiptError> {- let metadata = std::fs::symlink_metadata(path).map_err(|_| ReceiptError::Unavailable)?;- if !metadata.is_file() || metadata.file_type().is_symlink() {- return Err(ReceiptError::Unavailable);- }- Ok(())-}--fn now_ms() -> Result<u64, ReceiptError> {- SystemTime::now()- .duration_since(UNIX_EPOCH)- .map_err(|_| ReceiptError::Unavailable)- .and_then(|duration| {- u64::try_from(duration.as_millis()).map_err(|_| ReceiptError::Unavailable)- })-}--#[cfg(test)]-mod tests {- use super::*;- use serde_json::json;-- #[test]- fn receipt_rejects_same_key_with_changed_intent_and_stores_no_prompt() {- let root = tempfile::tempdir().unwrap();- let one = json!({"prompt":"secret one"});- let receipt = SubmissionReceipt::prepare_in(- root.path(),- "exec",- "same/key",- json!({"plan":"p"}),- &one,- )- .unwrap();- let receipt_path = receipt.path.clone();- receipt- .record("accepted", Some("task/one"), Some("run/one"))- .unwrap();- let stored = read_receipt(&receipt_path).unwrap();- assert_eq!(stored.task_id.as_deref(), Some("task/one"));- assert_eq!(stored.run_id.as_deref(), Some("run/one"));- let bytes = std::fs::read(&receipt_path).unwrap();- assert!(!String::from_utf8_lossy(&bytes).contains("secret one"));- let two = json!({"prompt":"secret two"});- assert_eq!(- SubmissionReceipt::prepare_in(- root.path(),- "exec",- "same/key",- json!({"plan":"p"}),- &two,- )- .err(),- Some(ReceiptError::Conflict)- );- }-}diff --git a/crates/cli/tests/contracts.rs b/crates/cli/tests/contracts.rsindex 97c01590..583511b7 100644--- a/crates/cli/tests/contracts.rs+++ b/crates/cli/tests/contracts.rs@@ -183,6 +183,20 @@ fn real_hiroute_help_exposes_both_public_contract_layers_without_a_daemon() {}}+#[test]+fn real_worker_help_requires_the_original_key_and_request_after_uncertain_delivery() {+ let output = Command::new(env!("CARGO_BIN_EXE_hiroute"))+ .args(["worker", "exec", "--help"])+ .output()+ .expect("launch real Worker help without a daemon");+ assert_eq!(output.status.code(), Some(0));+ assert!(output.stderr.is_empty());+ let help = String::from_utf8(output.stdout).unwrap();+ assert!(help.contains("without a local receipt"));+ assert!(help.contains("original key and the identical request"));+ assert!(!help.contains("A private receipt is saved before transmission"));+}+#[test]fn real_hiroute_launcher_emits_the_same_typed_manifest() {let cases: &[(&[&str], i32, &str)] = &[diff --git a/crates/cli/tests/worker_submission.rs b/crates/cli/tests/worker_submission.rsnew file mode 100644index 00000000..cb53475a--- /dev/null+++ b/crates/cli/tests/worker_submission.rs@@ -0,0 +1,454 @@+#![cfg(unix)]++//! Real CLI and Local Control boundary. The controlled owner records requests;+//! durable daemon admission and native Main behavior have separate acceptance.+use hiroute_application::{+ ApplicationService,+ delegation::tasks::{DelegationTaskPort, DelegationTasks},+};+use hiroute_application_api::{+ ClientHelloV1, DelegationAcceptedV1, DelegationGetV1, DelegationListV1,+ LocalControlWireRequestV2, RunStateV1, WorkerContinueRequestV1, WorkerExecRequestV1,+ WorkerListRequestV1, WorkerStatusRequestV1, negotiate_hello,+};+use hiroute_daemon::control::{ProductionControlRuntime, start_control};+use hiroute_domain::delegation::DelegationErrorV1;+use serde_json::{Value, json};+use std::io::{BufRead, BufReader, Write};+use std::os::unix::{fs::PermissionsExt, net::UnixListener};+use std::path::PathBuf;+use std::process::{Command, Output};+use std::sync::{Arc, Mutex};+use std::time::Duration;++#[derive(Default)]+struct Tasks {+ calls: Mutex<Vec<(bool, String, Value)>>,+}++impl Tasks {+ fn submit(+ &self,+ continuation: bool,+ key: &str,+ request: Value,+ ) -> Result<DelegationAcceptedV1, DelegationErrorV1> {+ let mut calls = self.calls.lock().unwrap();+ let previous = calls+ .iter()+ .position(|(op, old, _)| *op == continuation && old == key);+ let index = previous.unwrap_or(calls.len());+ let conflict = previous.is_some_and(|index| calls[index].2 != request);+ calls.push((continuation, key.to_owned(), request));+ if conflict {+ return Err(DelegationErrorV1::Conflict);+ }+ Ok(DelegationAcceptedV1 {+ schema: "hiroute.delegation-accepted/v1".into(),+ task_id: "task/fixture".into(),+ run_id: format!("run/{}", index + 1),+ title: Some("Recovery task".into()),+ state: RunStateV1::Accepted,+ state_revision: 1,+ replayed: previous.is_some(),+ })+ }++ fn task(&self) -> hiroute_application_api::DelegationTaskViewV1 {+ serde_json::from_value(json!({+ "task_id":"task/fixture", "created_at_ms":1, "latest_admission_sequence":1,+ "title":"Recovery task", "brief":"goal", "content_availability":"available",+ "plan_id":"plan/submission-fixture", "plan_revision":1, "latest_run_id":"run/1",+ "run":{+ "task_id":"task/fixture", "run_id":"run/1", "ordinal":1,+ "continued_from":null, "admission_sequence":1, "accepted_at_ms":1,+ "accepted_time_state":"recorded",+ "executor":{"harness":null,"display_name":null,"basis":"unavailable"},+ "state":"succeeded", "state_revision":2, "cleanup":"complete",+ "result_available":true,+ "scope":{"canonical_cwd":"/fixture", "permission_policy":"approve_all", "deadline_ms":1000}+ },+ "resumable_until_ms":null, "session_ids":[], "session_links_complete":true+ }))+ .unwrap()+ }+}++impl DelegationTaskPort for Tasks {+ fn worker_exec(+ &self,+ request: &WorkerExecRequestV1,+ ) -> Result<DelegationAcceptedV1, DelegationErrorV1> {+ self.submit(+ false,+ &request.submission_key,+ serde_json::to_value(request).unwrap(),+ )+ }++ fn worker_continue(+ &self,+ request: &WorkerContinueRequestV1,+ ) -> Result<DelegationAcceptedV1, DelegationErrorV1> {+ self.submit(+ true,+ &request.submission_key,+ serde_json::to_value(request).unwrap(),+ )+ }++ fn worker_status(+ &self,+ request: &WorkerStatusRequestV1,+ ) -> Result<DelegationGetV1, DelegationErrorV1> {+ assert!(+ self.calls+ .lock()+ .unwrap()+ .iter()+ .any(|(_, key, _)| { request.submission_key.as_deref() == Some(key.as_str()) })+ );+ Ok(DelegationGetV1 {+ schema: "hiroute.delegation-get/v1".into(),+ task: self.task(),+ })+ }++ fn worker_list(+ &self,+ request: &WorkerListRequestV1,+ ) -> Result<DelegationListV1, DelegationErrorV1> {+ assert_eq!(request.title.as_deref(), Some("Recovery task"));+ Ok(DelegationListV1 {+ schema: "hiroute.delegation-list/v1".into(),+ tasks: vec![self.task()],+ next_cursor: None,+ })+ }+}++struct Fixture {+ _root: tempfile::TempDir,+ _home: tempfile::TempDir,+ home: PathBuf,+ runtime: PathBuf,+ caller: PathBuf,+ worker: PathBuf,+}++impl Fixture {+ fn new() -> Self {+ let root = tempfile::tempdir_in("/tmp").unwrap();+ std::fs::create_dir_all(env!("CARGO_TARGET_TMPDIR")).unwrap();+ let home = tempfile::tempdir_in(env!("CARGO_TARGET_TMPDIR")).unwrap();+ let path = root.path().canonicalize().unwrap();+ let home_path = home.path().canonicalize().unwrap();+ let caller = path.join("caller");+ let worker = path.join("worker");+ std::fs::create_dir(&caller).unwrap();+ std::fs::create_dir(&worker).unwrap();+ Self {+ _root: root,+ _home: home,+ home: home_path,+ runtime: path.join("run"),+ caller,+ worker,+ }+ }++ fn command(&self) -> Command {+ let binary = std::env::var_os("HIROUTE_WORKER_SUBMISSION_REGRESSION_CLI")+ .unwrap_or_else(|| env!("CARGO_BIN_EXE_hiroute").into());+ let mut command = Command::new(binary);+ self.configure(&mut command);+ command+ }++ fn configure(&self, command: &mut Command) {+ command+ .env_clear()+ .env("PATH", "/usr/bin:/bin")+ .env("HOME", &self.home)+ .env("HIROUTE_RUNTIME_DIR", &self.runtime)+ .current_dir(&self.caller);+ }++ fn exec_args(&self, key: Option<&str>, goal: &str) -> Vec<String> {+ let mut args = vec![+ "worker",+ "exec",+ "--plan",+ "plan/submission-fixture",+ "--cwd",+ self.worker.to_str().unwrap(),+ "--title",+ "Recovery task",+ "--no-wait",+ "--output",+ "json",+ ];+ if let Some(key) = key {+ args.extend(["--submission-key", key]);+ }+ args.extend(["--", goal]);+ args.into_iter().map(str::to_owned).collect()+ }++ fn assert_no_workspace_receipt(&self) {+ assert!(!self.caller.join(".hiroute").exists());+ assert!(!self.worker.join(".hiroute").exists());+ }+}++impl Drop for Fixture {+ fn drop(&mut self) {+ let _ = std::fs::set_permissions(&self.caller, std::fs::Permissions::from_mode(0o700));+ }+}++fn with_control(run: impl FnOnce(&Fixture, &Tasks)) {+ let fixture = Fixture::new();+ let runtime = ProductionControlRuntime::open(fixture._root.path().join("storage")).unwrap();+ let tasks = Arc::new(Tasks::default());+ let ports = runtime+ .application_ports()+ .with_delegation_tasks(Arc::new(DelegationTasks::new(tasks.clone())));+ let mut control = start_control(ApplicationService::new(ports), &fixture.runtime).unwrap();+ run(&fixture, &tasks);+ control.shutdown();+ control.join(Duration::from_secs(5)).unwrap();+}++fn response(output: &Output) -> Value {+ serde_json::from_slice(&output.stdout).unwrap_or_else(|_| {+ panic!(+ "stdout={} stderr={}",+ String::from_utf8_lossy(&output.stdout),+ String::from_utf8_lossy(&output.stderr)+ )+ })+}++#[test]+fn obsolete_receipt_configuration_and_readonly_cwd_do_not_block_exec_replay_or_continue() {+ with_control(|fixture, tasks| {+ let legacy = fixture.home.join("legacy-receipts");+ std::fs::write(&legacy, b"existing-private-receipt-sentinel").unwrap();+ let original = std::fs::metadata(&legacy).unwrap().modified().unwrap();+ std::fs::set_permissions(&fixture.caller, std::fs::Permissions::from_mode(0o500)).unwrap();+ let invoke = |args: Vec<String>| {+ response(+ &fixture+ .command()+ .env("HIROUTE_WORKER_RECEIPT_DIR", &legacy)+ .args(args)+ .output()+ .unwrap(),+ )+ };+ let first = invoke(fixture.exec_args(Some("submission/original"), "goal"));+ assert_eq!(first["status"], "succeeded", "{first}");+ assert_eq!(first["data"]["submission_key"], "submission/original");+ let replay = invoke(fixture.exec_args(Some("submission/original"), "goal"));+ assert_eq!(replay["data"]["replayed"], true);+ assert_eq!(replay["data"]["run_id"], first["data"]["run_id"]);+ let changed = invoke(fixture.exec_args(Some("submission/original"), "different goal"));+ assert_eq!(changed["error"]["code"], "REVISION_CONFLICT");+ assert_eq!(+ tasks.calls.lock().unwrap().len(),+ 3,+ "conflict is owned by the server"+ );+ let continued = invoke(+ [+ "worker",+ "continue",+ "--task",+ "task/fixture",+ "--expected-latest-run",+ "run/1",+ "--submission-key",+ "submission/continued",+ "--no-wait",+ "--output",+ "json",+ "--",+ "continue goal",+ ]+ .into_iter()+ .map(str::to_owned)+ .collect(),+ );+ assert_eq!(continued["status"], "succeeded", "{continued}");+ assert_eq!(continued["data"]["submission_key"], "submission/continued");+ assert_eq!(+ std::fs::read(&legacy).unwrap(),+ b"existing-private-receipt-sentinel"+ );+ assert_eq!(+ std::fs::metadata(&legacy).unwrap().modified().unwrap(),+ original+ );+ fixture.assert_no_workspace_receipt();+ assert_eq!(std::fs::read_dir(&fixture.home).unwrap().count(), 1);+ });+}++#[test]+fn generated_key_is_returned_and_completed_task_can_be_queried_by_key_or_title() {+ with_control(|fixture, tasks| {+ let first = response(+ &fixture+ .command()+ .args(fixture.exec_args(None, "goal"))+ .output()+ .unwrap(),+ );+ let key = first["data"]["submission_key"].as_str().unwrap();+ let status = response(+ &fixture+ .command()+ .args([+ "worker",+ "status",+ "--submission-key",+ key,+ "--operation",+ "start",+ "--output",+ "json",+ ])+ .output()+ .unwrap(),+ );+ assert_eq!(status["data"]["task_id"], first["data"]["task_id"]);+ assert_eq!(status["data"]["run_state"], "succeeded");+ let listed = response(+ &fixture+ .command()+ .args([+ "worker",+ "list",+ "--title",+ "Recovery task",+ "--output",+ "json",+ ])+ .output()+ .unwrap(),+ );+ assert_eq!(+ listed["data"]["tasks"][0]["task_id"],+ first["data"]["task_id"]+ );+ assert_eq!(+ tasks.calls.lock().unwrap().len(),+ 1,+ "queries never resubmit work"+ );+ let second = response(+ &fixture+ .command()+ .args(fixture.exec_args(None, "goal"))+ .output()+ .unwrap(),+ );+ assert_ne!(second["data"]["submission_key"], key);+ assert_eq!(std::fs::read_dir(&fixture.home).unwrap().count(), 0);+ fixture.assert_no_workspace_receipt();+ });+}++#[test]+fn lost_response_keeps_the_key_and_recovery_action_without_resubmitting() {+ for key in [None, Some("submission/uncertain")] {+ let fixture = Fixture::new();+ let directory = fixture.runtime.join("hiroute");+ std::fs::create_dir_all(&directory).unwrap();+ std::fs::set_permissions(&directory, std::fs::Permissions::from_mode(0o700)).unwrap();+ let endpoint = directory.join("control.sock");+ let listener = UnixListener::bind(&endpoint).unwrap();+ std::fs::set_permissions(endpoint, std::fs::Permissions::from_mode(0o600)).unwrap();+ let server = std::thread::spawn(move || {+ let (stream, _) = listener.accept().unwrap();+ let mut stream = BufReader::new(stream);+ let mut line = String::new();+ stream.read_line(&mut line).unwrap();+ let hello: ClientHelloV1 = serde_json::from_str(&line).unwrap();+ let mut reply = serde_json::to_vec(&negotiate_hello(&hello).unwrap()).unwrap();+ reply.push(b'\n');+ stream.get_mut().write_all(&reply).unwrap();+ line.clear();+ stream.read_line(&mut line).unwrap();+ let request: LocalControlWireRequestV2 = serde_json::from_str(&line).unwrap();+ assert_eq!(request.operation_id, "WorkerExec");+ request.payload["submission_key"]+ .as_str()+ .unwrap()+ .to_owned()+ // The recorded request may have been accepted; the connection closes before reply.+ });+ let result = response(+ &fixture+ .command()+ .args(fixture.exec_args(key, "goal"))+ .output()+ .unwrap(),+ );+ let observed = server.join().unwrap();+ assert_eq!(result["data"]["submission_state"], "unknown");+ assert_eq!(result["data"]["submission_key"], observed);+ assert!(result["data"]["task_id"].is_null());+ assert_eq!(result["next_actions"][0]["command_id"], "worker.status");+ assert_eq!(+ result["next_actions"][0]["input"]["submission_key"],+ observed+ );+ assert_eq!(std::fs::read_dir(&fixture.home).unwrap().count(), 0);+ fixture.assert_no_workspace_receipt();+ }+}++#[cfg(target_os = "macos")]+#[test]+fn seatbelt_denies_local_file_writes_but_cli_can_submit_and_continue() {+ with_control(|fixture, tasks| {+ assert!(!fixture.home.starts_with("/private/tmp"));+ let policy = "(version 1)(allow default)(deny file-write*)";+ let binary = std::env::var_os("HIROUTE_WORKER_SUBMISSION_REGRESSION_CLI")+ .unwrap_or_else(|| env!("CARGO_BIN_EXE_hiroute").into());+ let invoke = |args: Vec<String>| {+ let mut command = Command::new("/usr/bin/sandbox-exec");+ command.args(["-p", policy]).arg(&binary);+ fixture.configure(&mut command);+ response(&command.args(args).output().unwrap())+ };+ let result = invoke(fixture.exec_args(None, "goal"));+ assert_eq!(result["status"], "succeeded", "{result}");+ let result = invoke(+ [+ "worker",+ "continue",+ "--task",+ "task/fixture",+ "--expected-latest-run",+ "run/1",+ "--submission-key",+ "submission/continued",+ "--no-wait",+ "--output",+ "json",+ "--",+ "continue goal",+ ]+ .into_iter()+ .map(str::to_owned)+ .collect(),+ );+ assert_eq!(result["status"], "succeeded", "{result}");+ assert_eq!(tasks.calls.lock().unwrap().len(), 2);+ assert_eq!(std::fs::read_dir(&fixture.home).unwrap().count(), 0);+ fixture.assert_no_workspace_receipt();+ });+}diff --git a/crates/daemon/src/control/runtime/settings_entry_collaboration_tests.rs b/crates/daemon/src/control/runtime/settings_entry_collaboration_tests.rsindex 3d67be26..87b2b96a 100644--- a/crates/daemon/src/control/runtime/settings_entry_collaboration_tests.rs+++ b/crates/daemon/src/control/runtime/settings_entry_collaboration_tests.rs@@ -1,4 +1,10 @@use super::*;+use std::os::unix::fs::MetadataExt;++const RELEASED_EXPLICIT_SKILL: &str =+ include_str!("../../../tests/fixtures/collaboration-skill-v0.3.1/explicit.md");+const RELEASED_DEFAULT_SKILL: &str =+ include_str!("../../../tests/fixtures/collaboration-skill-v0.3.1/default.md");#[test]fn v2_settings_skill_only_enable_change_and_disable_keep_model_untouched() {@@ -122,18 +128,55 @@ fn v2_settings_skill_only_enable_change_and_disable_keep_model_untouched() {fs::write(&legacy, sealed.as_bytes()).unwrap();fs::set_permissions(&legacy, fs::Permissions::from_mode(0o600)).unwrap();+ let skill = home.join(".agents/skills/hiroute-collaboration/SKILL.md");+ let install_released = |spec: serde_json::Value,+ revision: &'static str,+ content: &'static str,+ key: &str| {+ let released = LocalControlDaemon::new(ApplicationService::new(+ runtime.application_ports().with_agent_connection(Arc::new(+ FixtureFacts::released_collaboration(runtime.adapter.clone(), revision, content),+ )),+ ));+ let accepted = apply(&released, &runtime, spec, key);+ assert_eq!(fs::read_to_string(&skill).unwrap(), content);+ let id: OperationId = serde_json::from_value(accepted["operation_id"].clone()).unwrap();+ let operation = runtime+ .adapter+ .stores_lock()+ .unwrap()+ .control()+ .load_operation(&id)+ .unwrap()+ .unwrap();+ (id, serde_json::to_vec(&operation).unwrap())+ };+ let (released_id, released_operation) = install_released(+ enable.clone(),+ "worker-instance-default-v1",+ RELEASED_DEFAULT_SKILL,+ "released-default-skill",+ );let enabled = apply(&service, &runtime, enable, "skill-enable");assert!(!legacy.exists());assert_local_worker_collaboration_management(&service, &context, "delegate_by_default");- let skill = home.join(".agents/skills/hiroute-collaboration/SKILL.md");let content = fs::read_to_string(&skill).unwrap();assert!(content.contains("Delegate suitable executable work by default"));assert!(content.contains("hiroute worker plans"));+ assert!(content.contains("literal value in `--submission-key`"));+ assert!(content.contains("An empty list or unclear match"));assert!(!content.contains("--agent"));assert!(content.contains("use a restricted policy only when the user asks for one and the selected harness supports it"));assert_eq!(fs::read(&model).unwrap(), original_model);+ assert_skill_upgrade(+ &runtime,+ &released_id,+ &released_operation,+ "default",+ &content,+ );fs::write(&legacy, b"not a sealed HiRoute artifact").unwrap();fs::set_permissions(&legacy, fs::Permissions::from_mode(0o600)).unwrap();@@ -159,7 +202,13 @@ fn v2_settings_skill_only_enable_change_and_disable_keep_model_untouched() {"schema_version":{"major":2,"minor":0}, "context_id":context,"collaboration":{"intent":"configure","settings":{"trigger_mode":"explicit"}}});- let changed = apply(&service, &runtime, change, "skill-change");+ let (released_id, released_operation) = install_released(+ change.clone(),+ "worker-instance-explicit-v1",+ RELEASED_EXPLICIT_SKILL,+ "released-explicit-skill",+ );+ let changed = apply(&service, &runtime, change.clone(), "skill-change");let changed_id: OperationId = serde_json::from_value(changed["operation_id"].clone()).unwrap();let changed_operation = runtime.adapter@@ -171,18 +220,32 @@ fn v2_settings_skill_only_enable_change_and_disable_keep_model_untouched() {.unwrap();assert!(!changed_operation.plan.external().is_empty(),- "changing the trigger mode rewrites the owned Skill content"+ "changing the template revision rewrites the owned Skill content");let changed_content = fs::read_to_string(&skill).unwrap();assert_ne!(changed_content, content);assert!(changed_content.contains("only when the user explicitly asks"));+ assert!(changed_content.contains("literal value in `--submission-key`"));+ assert_skill_upgrade(+ &runtime,+ &released_id,+ &released_operation,+ "explicit",+ &changed_content,+ );+ let inode = fs::metadata(&skill).unwrap().ino();+ let reapplied = apply(&service, &runtime, change, "skill-reapply-identical");+ let reapplied_id: OperationId =+ serde_json::from_value(reapplied["operation_id"].clone()).unwrap();+ assert_eq!(fs::read_to_string(&skill).unwrap(), changed_content);+ assert_eq!(fs::metadata(&skill).unwrap().ino(), inode);assert_local_worker_collaboration_management(&service, &context, "explicit");assert_eq!(fs::read(&model).unwrap(), original_model);assert_worker_plans_empty(&service, "worker-plans-after-change");let disable = json!({"schema_version":{"major":2,"minor":0}, "context_id":context,- "collaboration":{"intent":"restore","restore_point_ref":codex_model_restore_point_ref(&changed_id)}+ "collaboration":{"intent":"restore","restore_point_ref":codex_model_restore_point_ref(&reapplied_id)}});apply(&service, &runtime, disable, "skill-disable");assert!(!skill.exists());@@ -199,6 +262,40 @@ fn v2_settings_skill_only_enable_change_and_disable_keep_model_untouched() {assert_worker_plans_empty(&service, "worker-plans-after-disable");}+fn assert_skill_upgrade(+ runtime: &ProductionControlRuntime,+ released_id: &OperationId,+ released_operation: &[u8],+ mode: &str,+ content: &str,+) {+ let stores = runtime.adapter.stores_lock().unwrap();+ let record = stores+ .control()+ .skill_installation(&WorkspaceId::default(), "skill-root/agent_codex_default")+ .unwrap()+ .unwrap();+ assert_eq!(+ record.template_revision,+ format!("worker-instance-{mode}-v2")+ );+ assert!(record.revision > 1);+ assert_eq!(+ record.content_digest,+ CanonicalDigest::of_bytes(content.as_bytes())+ );+ assert_eq!(+ record.file_ownership,+ hiroute_domain::CollaborationSkillFileOwnership::Managed+ );+ let unchanged = stores+ .control()+ .load_operation(released_id)+ .unwrap()+ .unwrap();+ assert_eq!(serde_json::to_vec(&unchanged).unwrap(), released_operation);+}+#[test]fn v2_settings_releases_borrowed_skill_after_user_file_drift() {if crate::test_support::isolated_agent_home(@@ -206,7 +303,6 @@ fn v2_settings_releases_borrowed_skill_after_user_file_drift() {) {return;}- use std::os::unix::fs::MetadataExt;let root = tempfile::tempdir().unwrap();fs::set_permissions(root.path(), fs::Permissions::from_mode(0o700)).unwrap();diff --git a/crates/daemon/src/control/runtime/settings_entry_tests.rs b/crates/daemon/src/control/runtime/settings_entry_tests.rsindex 9ef74f11..341b4479 100644--- a/crates/daemon/src/control/runtime/settings_entry_tests.rs+++ b/crates/daemon/src/control/runtime/settings_entry_tests.rs@@ -959,6 +959,7 @@ fn request(struct FixtureFacts {adapter: Arc<LocalControlAdapter>,fixture_worker_metadata: bool,+ released_skill: Option<(&'static str, &'static str)>,}impl FixtureFacts {@@ -966,6 +967,7 @@ impl FixtureFacts {Self {adapter,fixture_worker_metadata: false,+ released_skill: None,}}@@ -973,6 +975,18 @@ impl FixtureFacts {Self {adapter,fixture_worker_metadata: true,+ released_skill: None,+ }+ }++ fn released_collaboration(+ adapter: Arc<LocalControlAdapter>,+ revision: &'static str,+ content: &'static str,+ ) -> Self {+ Self {+ released_skill: Some((revision, content)),+ ..Self::collaboration(adapter)}}}@@ -997,6 +1011,19 @@ impl AgentConnectionControlPort for FixtureFacts {spec: &api::AgentSettingsSpecV2,) -> Result<AgentSettingsPlanningInput, ControlReadError> {let mut input = self.adapter.capture_settings_facts(spec)?;+ if let Some((revision, content)) = self.released_skill {+ input.skill_file.template =+ hiroute_application::agent_connection::CollaborationSkillTemplate::bundled(+ revision, content,+ )+ .map_err(|_| ControlReadError::Corrupt)?;+ input.facts.dependency_digest = CanonicalDigest::of(&(+ revision,+ &input.skill_file.template.digest,+ &input.facts.dependency_digest,+ ))+ .map_err(|_| ControlReadError::Corrupt)?;+ }// The fixture proves the public settings transaction and catalog capability boundary;// native fixed-source associations are not supplied by this isolated environment.if self.fixture_worker_metadata {diff --git a/crates/daemon/src/control/runtime/settings_facts.rs b/crates/daemon/src/control/runtime/settings_facts.rsindex 02ee7bea..3c581ae9 100644--- a/crates/daemon/src/control/runtime/settings_facts.rs+++ b/crates/daemon/src/control/runtime/settings_facts.rs@@ -39,10 +39,10 @@ use codex_association::{connector_account_matches, endpoint_matches_target, mark_catalog_structure_proven,};-const COLLABORATION_SKILL_EXPLICIT_REVISION: &str = "worker-instance-explicit-v1";-const COLLABORATION_SKILL_DEFAULT_REVISION: &str = "worker-instance-default-v1";-const COLLABORATION_SKILL_EXPLICIT_CONTENT: &str = "---\nname: hiroute-collaboration\ndescription: Delegate through HiRoute only when the user explicitly asks for delegation.\n---\n\n# HiRoute collaboration\n\nUse delegation only when the user explicitly requests it. Before delegating, run `hiroute worker plans` and select a published plan whose stated purpose matches the work; if none matches, say so instead of inventing one.\n\nStart executable work with `hiroute worker exec --plan <ID> --cwd <PATH> ...`. Permission policy defaults to `approve-all`; use a restricted policy only when the user asks for one and the selected harness supports it. Supply exactly one input source and keep the returned submission key, task ID, and run ID. Use the response's next actions to read progress, check status, wait, fetch results, continue, or recover an uncertain submission. Never replace an uncertain submission key automatically.\n\nDo not delegate coordination, plan discovery, status checks, waits, result summaries, or another delegation. A Worker must not recursively delegate. Never request or expose grants, capabilities, root identities, digests, revisions, credentials, or native session material.\n";-const COLLABORATION_SKILL_DEFAULT_CONTENT: &str = "---\nname: hiroute-collaboration\ndescription: Delegate suitable executable work through HiRoute by default.\n---\n\n# HiRoute collaboration\n\nDelegate suitable executable work by default. Before delegating, run `hiroute worker plans` and select a published plan whose stated purpose matches the work; if none matches, say so instead of inventing one.\n\nStart executable work with `hiroute worker exec --plan <ID> --cwd <PATH> ...`. Permission policy defaults to `approve-all`; use a restricted policy only when the user asks for one and the selected harness supports it. Supply exactly one input source and keep the returned submission key, task ID, and run ID. Use the response's next actions to read progress, check status, wait, fetch results, continue, or recover an uncertain submission. Never replace an uncertain submission key automatically.\n\nDo not delegate coordination, plan discovery, status checks, waits, result summaries, or another delegation. A Worker must not recursively delegate. Never request or expose grants, capabilities, root identities, digests, revisions, credentials, or native session material.\n";+const COLLABORATION_SKILL_EXPLICIT_REVISION: &str = "worker-instance-explicit-v2";+const COLLABORATION_SKILL_DEFAULT_REVISION: &str = "worker-instance-default-v2";+const COLLABORATION_SKILL_EXPLICIT_CONTENT: &str = "---\nname: hiroute-collaboration\ndescription: Delegate through HiRoute only when the user explicitly asks for delegation.\n---\n\n# HiRoute collaboration\n\nUse delegation only when the user explicitly requests it. Before delegating, run `hiroute worker plans` and select a published plan whose stated purpose matches the work; if none matches, say so instead of inventing one.\n\nStart executable work with `hiroute worker exec --plan <ID> --cwd <PATH> ...`. Permission policy defaults to `approve-all`; use a restricted policy only when the user asks for one and the selected harness supports it. For each new exec or continue, choose a unique submission key and put its literal value in `--submission-key` before invoking the CLI; do not generate it dynamically inside the command. Reuse that key only when retrying the identical request. Use a short recognizable `--title` for a new task. Supply exactly one input source and keep the submission key, task ID, and run ID in the conversation. The CLI keeps no local submission receipt. Use the response's next actions to read progress, check status, wait, fetch results, continue, or recover an uncertain submission. If a response is lost, query `hiroute worker status --submission-key <ORIGINAL_KEY> --operation <start|continue>` first. If the key is lost, use `hiroute worker list --title <TITLE>`, follow all pages, and confirm the workspace, time and task details before using an existing task ID. Titles may repeat and disappear after seven days or content deletion. An empty list or unclear match does not prove that submission failed: stop and ask the user instead of automatically submitting again or replacing the key.\n\nDo not delegate coordination, plan discovery, status checks, waits, result summaries, or another delegation. A Worker must not recursively delegate. Never request or expose grants, capabilities, root identities, digests, revisions, credentials, or native session material.\n";+const COLLABORATION_SKILL_DEFAULT_CONTENT: &str = "---\nname: hiroute-collaboration\ndescription: Delegate suitable executable work through HiRoute by default.\n---\n\n# HiRoute collaboration\n\nDelegate suitable executable work by default. Before delegating, run `hiroute worker plans` and select a published plan whose stated purpose matches the work; if none matches, say so instead of inventing one.\n\nStart executable work with `hiroute worker exec --plan <ID> --cwd <PATH> ...`. Permission policy defaults to `approve-all`; use a restricted policy only when the user asks for one and the selected harness supports it. For each new exec or continue, choose a unique submission key and put its literal value in `--submission-key` before invoking the CLI; do not generate it dynamically inside the command. Reuse that key only when retrying the identical request. Use a short recognizable `--title` for a new task. Supply exactly one input source and keep the submission key, task ID, and run ID in the conversation. The CLI keeps no local submission receipt. Use the response's next actions to read progress, check status, wait, fetch results, continue, or recover an uncertain submission. If a response is lost, query `hiroute worker status --submission-key <ORIGINAL_KEY> --operation <start|continue>` first. If the key is lost, use `hiroute worker list --title <TITLE>`, follow all pages, and confirm the workspace, time and task details before using an existing task ID. Titles may repeat and disappear after seven days or content deletion. An empty list or unclear match does not prove that submission failed: stop and ask the user instead of automatically submitting again or replacing the key.\n\nDo not delegate coordination, plan discovery, status checks, waits, result summaries, or another delegation. A Worker must not recursively delegate. Never request or expose grants, capabilities, root identities, digests, revisions, credentials, or native session material.\n";struct CodexRestoreModelFacts {ids: Option<Vec<String>>,diff --git a/crates/daemon/tests/fixtures/collaboration-skill-v0.3.1/README.md b/crates/daemon/tests/fixtures/collaboration-skill-v0.3.1/README.mdnew file mode 100644index 00000000..99e0183b--- /dev/null+++ b/crates/daemon/tests/fixtures/collaboration-skill-v0.3.1/README.md@@ -0,0 +1,13 @@+# Released collaboration Skill fixtures++Frozen bytes from public v0.3.1 source `13856abd873da5b4373d39322493b4cc105c4867`,+`crates/daemon/src/control/runtime/settings_facts.rs`, constants+`COLLABORATION_SKILL_EXPLICIT_CONTENT` and `COLLABORATION_SKILL_DEFAULT_CONTENT`.++These fixtures are installed through the normal test settings transaction before+current Configure/Apply replaces a HiRoute-owned file. They are never production+input or regenerated from the current template. User-owned/borrowed files retain+the existing conflict boundary. Startup alone does not update an installed Skill.++- `explicit.md`: SHA-256 `e11ca8ebf95e5e685fecb6998aa4452d6e869fcef548a69573aea779084e001b`.+- `default.md`: SHA-256 `1f3519860f3927481a18ba9204d1f2a2d6bfba5288680f7b14f913b53d3a02d3`.diff --git a/crates/daemon/tests/fixtures/collaboration-skill-v0.3.1/default.md b/crates/daemon/tests/fixtures/collaboration-skill-v0.3.1/default.mdnew file mode 100644index 00000000..9aa3b71b--- /dev/null+++ b/crates/daemon/tests/fixtures/collaboration-skill-v0.3.1/default.md@@ -0,0 +1,12 @@+---+name: hiroute-collaboration+description: Delegate suitable executable work through HiRoute by default.+---++# HiRoute collaboration++Delegate suitable executable work by default. Before delegating, run `hiroute worker plans` and select a published plan whose stated purpose matches the work; if none matches, say so instead of inventing one.++Start executable work with `hiroute worker exec --plan <ID> --cwd <PATH> ...`. Permission policy defaults to `approve-all`; use a restricted policy only when the user asks for one and the selected harness supports it. Supply exactly one input source and keep the returned submission key, task ID, and run ID. Use the response's next actions to read progress, check status, wait, fetch results, continue, or recover an uncertain submission. Never replace an uncertain submission key automatically.++Do not delegate coordination, plan discovery, status checks, waits, result summaries, or another delegation. A Worker must not recursively delegate. Never request or expose grants, capabilities, root identities, digests, revisions, credentials, or native session material.diff --git a/crates/daemon/tests/fixtures/collaboration-skill-v0.3.1/explicit.md b/crates/daemon/tests/fixtures/collaboration-skill-v0.3.1/explicit.mdnew file mode 100644index 00000000..8a0e7656--- /dev/null+++ b/crates/daemon/tests/fixtures/collaboration-skill-v0.3.1/explicit.md@@ -0,0 +1,12 @@+---+name: hiroute-collaboration+description: Delegate through HiRoute only when the user explicitly asks for delegation.+---++# HiRoute collaboration++Use delegation only when the user explicitly requests it. Before delegating, run `hiroute worker plans` and select a published plan whose stated purpose matches the work; if none matches, say so instead of inventing one.++Start executable work with `hiroute worker exec --plan <ID> --cwd <PATH> ...`. Permission policy defaults to `approve-all`; use a restricted policy only when the user asks for one and the selected harness supports it. Supply exactly one input source and keep the returned submission key, task ID, and run ID. Use the response's next actions to read progress, check status, wait, fetch results, continue, or recover an uncertain submission. Never replace an uncertain submission key automatically.++Do not delegate coordination, plan discovery, status checks, waits, result summaries, or another delegation. A Worker must not recursively delegate. Never request or expose grants, capabilities, root identities, digests, revisions, credentials, or native session material.diff --git a/crates/daemon/tests/support/claude_subscription_catalog_product.py b/crates/daemon/tests/support/claude_subscription_catalog_product.pyindex 68051fea..15b0e5b4 100644--- a/crates/daemon/tests/support/claude_subscription_catalog_product.py+++ b/crates/daemon/tests/support/claude_subscription_catalog_product.py@@ -220,7 +220,7 @@ def run(repository, label):# inherited alternative configuration is admitted to this regression process.product.env = {key: value for key, value in product.env.items() if key in ('HOME', 'CODEX_HOME', 'CLAUDE_CONFIG_DIR', 'QODER_CONFIG_DIR', 'PI_CODING_AGENT_DIR',- 'DSH_HOME', 'PATH', 'HIROUTE_RUNTIME_DIR', 'HIROUTE_WORKER_RECEIPT_DIR', 'HIROUTE_REPLAY_ROOT',+ 'DSH_HOME', 'PATH', 'HIROUTE_RUNTIME_DIR', 'HIROUTE_REPLAY_ROOT','LANG', 'LC_ALL', 'LC_CTYPE', 'TZ', 'SSL_CERT_FILE', 'SSL_CERT_DIR')}home = Path(product.env['HOME'])product.env.update(XDG_CONFIG_HOME=str(home / '.config'), XDG_CACHE_HOME=str(home / '.cache'),diff --git a/crates/daemon/tests/support/publication_product.py b/crates/daemon/tests/support/publication_product.pyindex afab77d0..8e185fb6 100644--- a/crates/daemon/tests/support/publication_product.py+++ b/crates/daemon/tests/support/publication_product.py@@ -192,7 +192,6 @@ finally:DSH_HOME=str(home / '.dsh'),PATH=str(bin_dir) + ':/usr/bin:/bin',HIROUTE_RUNTIME_DIR=str(self.root / 'runtime'),- HIROUTE_WORKER_RECEIPT_DIR=str(self.root / 'worker-receipts'),HIROUTE_REPLAY_ROOT=str(self.root / 'replay'))self.listener_port_lease, self.port = fixture_listener_port()self.process = Nonediff --git a/docs/code-map/testing.md b/docs/code-map/testing.mdindex b383abd5..a3a85874 100644--- a/docs/code-map/testing.md+++ b/docs/code-map/testing.md@@ -48,8 +48,11 @@ mutations. Main-Agent delegation must separately invoke the actual public CLI.Keep borrowed user resources, writable native acceptance configuration, freshproduct storage and per-run materials separate. Each product instance needs a-private `HIROUTE_WORKER_RECEIPT_DIR`, propagated to public CLI subprocesses and-stable for retries. Expose the selected CLI and Pi's selected Node consistently+private runtime/storage namespace. CLI submissions have no local receipt directory;+recovery uses the original key and request, with title/detail lookup only as an aid.+[CLI submission regressions](../../crates/cli/tests/worker_submission.rs) cover denied local+writes and uncertain responses; durable admission and native Main journeys remain separate.+Expose the selected CLI and Pi's selected Node consistentlyto main-Agent checks and Worker launch. Never repair permissions on pre-existinguser directories to satisfy a fixture; cleanup verifies the owned object'sidentity and preserves foreign files.diff --git a/docs/code-map/worker-context.md b/docs/code-map/worker-context.mdindex 1ef95a02..5b6a342f 100644--- a/docs/code-map/worker-context.md+++ b/docs/code-map/worker-context.md@@ -31,7 +31,7 @@ restoration must verify ownership rather than infer it from a provider name.| --- | --- | --- || Select and confirm an installation | [Desktop preparation](../../apps/desktop/src-tauri/src/bridge/worker_tasks.rs), [protected confirmation](../../apps/desktop/src-tauri/src/session/worker_dependencies.rs), [launch type](../../crates/domain/src/delegation/installation.rs), [storage](../../crates/local-storage/src/control/worker_dependencies.rs) | Exact canonical components, window-bound single-use confirmation and durable selection; discovery is not authority || Publish the machine-readable request shape | [Worker producer](../../crates/application-api/src/generated/worker.rs), [Plan producer](../../crates/application-api/src/generated/plan_authoring.rs), [CLI generator](../../crates/cli/src/bin/generate_cli_contract.rs) | Typed producer sources generate [CLI contracts](../../contracts/cli); retain native-only forbidden fields and adapter requirements |-| Submit and admit work | [CLI receipts](../../crates/cli/src/worker/receipt.rs), [daemon admission](../../crates/daemon/src/control/runtime/delegation_tasks.rs), [Application](../../crates/application/src/delegation) | A local idempotency conflict is distinct from daemon admission; freeze intent, Plan and task identity |+| Submit and admit work | [CLI submission](../../crates/cli/src/worker.rs), [daemon admission](../../crates/daemon/src/control/runtime/delegation_tasks.rs), [Application](../../crates/application/src/delegation) | Daemon admission owns durable key/intent deduplication; CLI preserves returned locators and uses no local receipt || Resolve resources and construct a run | [Installation](../../crates/daemon/src/delegation/installation.rs), [native context](../../crates/daemon/src/delegation/profile/native_context.rs), [profile guide](../../crates/daemon/src/delegation/profile/README.md) | Effective instance HOME/config root supplies resources; per-run overrides supply route, credential and permission policy || Project native context/output budgets | [Shared budget policy](../../crates/domain/src/agents/additional_model.rs), [native projection](../../crates/integrations/src/agents/qoder_budget.rs) | Preserve the frozen Plan's active-candidate/protocol bounds; Gateway output capping alone cannot prove native compaction limits || Admit and attribute model requests | [Run authority](../../crates/daemon/src/delegation/run_authority.rs), [Gateway dispatch](../../crates/gateway/src/dispatch/run.rs) | Sealed Plan, live run, harness, protocol and observation identity must agree |diff --git a/docs/standalone-cli.md b/docs/standalone-cli.mdindex 02a5810c..d368b731 100644--- a/docs/standalone-cli.md+++ b/docs/standalone-cli.md@@ -478,6 +478,10 @@ The workflow also accepts other supported Agent IDs returned by scan. Like Desktthe collaboration context: Codex uses `codex_access.root_context_id` even with an occupiedmodel profile, and other Agents use their own context. Model and access-token settings remain.+After upgrading HiRoute, save collaboration configuration again with the same trigger and a+new configuration idempotency key to update a HiRoute-owned installed Skill. Startup alone+does not replace it. Modified or user-owned Skill files retain the existing conflict rules.+`--preview` runs no local check, writes no submission record and saves no configuration.A save runs an existing bounded local check only for missing capabilities reported by Preview,then previews again. It makes no provider model call. Failed checks, file conflicts or remaining@@ -697,6 +701,16 @@ through the same `worker exec`; never replace the key. Duplicate submission returun and does not execute twice. `selection_revision` is the concurrency revision for Workerinstallation selection, not a Codex, Claude, or HiRoute CLI/package version.+The CLI writes no local submission receipt, needs no writable receipt directory, and ignores+`HIROUTE_WORKER_RECEIPT_DIR`. Existing receipt files are left untouched. Prefer a unique literal+`--submission-key` chosen before each new submission and retain it with the original request.+An omitted key is generated and returned by the CLI; a crash before receiving that output can+lose it. If the key is lost, `hiroute worker list --title TITLE --output json` can help locate a+task: follow all pages and verify its time, Plan, cwd and details. Titles can repeat and are+visible only while the initial input remains available (seven days, or until earlier content+deletion), including after completion. If no unambiguous match exists, ask for confirmation;+never automatically create a replacement task from an empty search result.+## Gateway listener```shdiff --git a/docs/standalone-cli.zh-CN.md b/docs/standalone-cli.zh-CN.mdindex 1fce9ae5..55831de1 100644--- a/docs/standalone-cli.zh-CN.md+++ b/docs/standalone-cli.zh-CN.md@@ -407,6 +407,9 @@ hiroute agents collaboration disable agent_codex_default --yes --idempotency-key`codex_access.root_context_id`,模型 profile 已配置时也使用原始 HOME 的 root context;其他 Agent 使用自己的 context。模型和访问 token 保持原设置。+升级 HiRoute 后,以相同触发方式和新的配置提交标识重新保存协作配置,才能更新 HiRoute+管理的已安装 Skill;仅启动不会替换它。用户修改或自行维护的 Skill 仍遵守原有冲突规则。+`--preview` 不执行本地检查、写入提交记录或保存配置。实际保存仅在预览报告能力证明缺失时执行既有的本地有界检查,然后重新预览,不产生上游模型调用。检查失败、文件冲突或仍有blocker 时停止保存。关闭使用协作自己的 restore point,并要求 `--yes` 确认。@@ -600,6 +603,13 @@ hiroute worker list --output json`worker exec`;不要换 key。重复提交返回同一个 run,不会执行两次。`selection_revision` 是 Worker选择配置的并发版本,不是 Codex、Claude 或 HiRoute 软件版本。+CLI 不写本地提交收据,无需可写的收据目录,也不再使用 `HIROUTE_WORKER_RECEIPT_DIR`;+已有收据文件保留原样。每次新提交优先预先选定唯一编号,将其字面值传入 `--submission-key`,+并在对话或工具调用记录里保留编号和原请求。未指定编号时 CLI 仍会生成并返回,但在响应到达前+崩溃可能丢失编号。编号丢失时可用 `hiroute worker list --title TITLE --output json` 辅助找回:+遍历分页并核对时间、Plan、目录和任务详情。标题可能重名,随首次输入内容保留七天或在提前+删除内容后隐藏,完成任务也遵守同一规则。不能明确匹配时请求确认,不因列表为空自动新建任务。+## Gateway 监听器```shdiff --git a/e2e/product/schema/contract-set.v1.json b/e2e/product/schema/contract-set.v1.jsonindex 77463da5..4cf960b0 100644--- a/e2e/product/schema/contract-set.v1.json+++ b/e2e/product/schema/contract-set.v1.json@@ -1,10 +1,10 @@{- "descriptor_digest": "sha256:1bdd37be3354af88208d5c9f91945f23b392c2bce3eb8ceb5677fa945126d4c5",+ "descriptor_digest": "sha256:3ae32fc9b7da19b9d8b23ffefd8a25bc221dc86adc3bdbaca761f176928508b9","files": {"dependency-gate.v1.json": "sha256:b8ac81155266dca921f159d1cfabec6605f2e4bab0320ad6b23a3dbee51e6fa1","product-action.v1.schema.json": "sha256:faf815b27fd292e564a7d51de20c5a2825abbe710315a2364a9932ae3b5e4b7e","product-oracle-evidence.v1.schema.json": "sha256:faab6582bf3fba307b0f9f2949c51726409a209b0fa62e847114e0c6301038c6",- "product-oracle-manifest.v1.json": "sha256:238789cb8c23435d4401b3b3e5522cca6b4d70bd1d411b20a25dec475c5232e5",+ "product-oracle-manifest.v1.json": "sha256:838a238f2e3e8e890106a3959f4c89bd1dbfedb9e35df0311666bf2547107f5e","product-result.v1.schema.json": "sha256:72fc76be77572e40eed7516754911b45fdc9d55a8c089ba74c21427a33809def"},"schema_version": {diff --git a/e2e/product/schema/product-oracle-manifest.v1.json b/e2e/product/schema/product-oracle-manifest.v1.jsonindex 04ad540f..fdd5f8a9 100644--- a/e2e/product/schema/product-oracle-manifest.v1.json+++ b/e2e/product/schema/product-oracle-manifest.v1.json@@ -1,5 +1,5 @@{- "descriptor_digest": "sha256:1bdd37be3354af88208d5c9f91945f23b392c2bce3eb8ceb5677fa945126d4c5",+ "descriptor_digest": "sha256:3ae32fc9b7da19b9d8b23ffefd8a25bc221dc86adc3bdbaca761f176928508b9","expected_red_reasons": [],"planned_commands": ["schema.list",diff --git a/scripts/ci-shards.py b/scripts/ci-shards.pyindex e1a8cbee..18d9a26f 100755--- a/scripts/ci-shards.py+++ b/scripts/ci-shards.py@@ -37,6 +37,7 @@ INTEGRATION_SHARDS = {("hiroute-cli", "transport_unavailable"),("hiroute-cli", "work_plans"),("hiroute-cli", "worker_dependencies"),+ ("hiroute-cli", "worker_submission"),("hiroute-integrations", "agent_profiles"),("hiroute-integrations", "claude_subscription_catalog"),("hiroute-integrations", "current_model_metadata"),diff --git a/scripts/cpa-managed-login-live.py b/scripts/cpa-managed-login-live.pyindex 194a3c07..0b14d81c 100644--- a/scripts/cpa-managed-login-live.py+++ b/scripts/cpa-managed-login-live.py@@ -125,7 +125,6 @@ def isolated_environment(root):XDG_DATA_HOME=str(home / '.local/share'), TMPDIR=str(Path(root) / 'tmp'),PATH=str(Path(root) / 'bin') + ':/usr/local/bin:/usr/bin:/bin',HIROUTE_RUNTIME_DIR=str(Path(root) / 'runtime'),- HIROUTE_WORKER_RECEIPT_DIR=str(Path(root) / 'worker-receipts'),HIROUTE_REPLAY_ROOT=str(Path(root) / 'replay'))return envdiff --git a/scripts/test-native-context-product.py b/scripts/test-native-context-product.pyindex f6a316a7..2181294b 100644--- a/scripts/test-native-context-product.py+++ b/scripts/test-native-context-product.py@@ -284,16 +284,7 @@ with patch('publication_product.secrets.SystemRandom') as chooser:self.assertEqual(product.env['CLAUDE_CONFIG_DIR'], str(home / '.claude'))self.assertEqual(product.env['QODER_CONFIG_DIR'], str(home / '.qoder'))self.assertEqual(product.env['PI_CODING_AGENT_DIR'], str(home / '.pi/agent'))- receipt_root = str(product.root / 'worker-receipts')- self.assertEqual(product.env['HIROUTE_WORKER_RECEIPT_DIR'], receipt_root)- # Borrowing a normally logged-in native HOME must not borrow HiRoute's- # client submission journal or collide with earlier acceptance runs.- product.env['HOME'] = '/explicitly-borrowed/native-home'- self.assertEqual(product.env['HIROUTE_WORKER_RECEIPT_DIR'], receipt_root)- neighbor = Product(REPO, root=self.root / 'neighbor-product')- self.addCleanup(neighbor.close)- neighbor.env['HOME'] = product.env['HOME']- self.assertNotEqual(neighbor.env['HIROUTE_WORKER_RECEIPT_DIR'], receipt_root)+ self.assertNotIn('HIROUTE_WORKER_RECEIPT_DIR', product.env)for key in ('CLAUDE_CODE_OAUTH_TOKEN', 'CODEX_CONFIG', 'AWS_PROFILE', 'QODER_PERSONAL_ACCESS_TOKEN','DEEPSEEK_API_KEY', 'GROQ_API_KEY', 'MISTRAL_API_KEY', 'XAI_API_KEY', 'CEREBRAS_API_KEY'):self.assertNotIn(key, product.env)diff --git a/tools/product-e2e/tests/QODER_DELEGATION.md b/tools/product-e2e/tests/QODER_DELEGATION.mdindex 604846f1..4d7e5133 100644--- a/tools/product-e2e/tests/QODER_DELEGATION.md+++ b/tools/product-e2e/tests/QODER_DELEGATION.md@@ -83,10 +83,11 @@ context and CLI version; do not generalize this observation to other accounts orversions. A no-login result from a dedicated acceptance HOME says nothing aboutthe user's separately logged-in daily HOME.-HiRoute's CLI submission receipts always use the Product's explicit private-`HIROUTE_WORKER_RECEIPT_DIR`, even when native HOME is borrowed. Repeated submissions-within one journey keep that directory so replay/conflict behavior remains real;-separate acceptance runs must not reuse the daily client's journal.+HiRoute CLI submissions write no local receipt, including when native HOME is borrowed.+Each Product owns its runtime/storage namespace. A retry uses the original literal+submission key and unchanged request; a new journey gets a fresh key. Recovery queries+that key first, with title/detail lookup only as an aid. Never resubmit an uncertain+request merely because a title search is empty or ambiguous.The real collaboration Skill must be installed by the production settingsoperation at `<QODER_CONFIG_DIR>/skills/hiroute-collaboration/SKILL.md`. There is no