Code/docs quality re-review for repo /Users/molt/dev/rightclaw/.worktrees/providers-v2-bulletproof-composition at current HEAD a1e4f675. Do not edit files.
Focus on the endpoint-aware provider composition fix: crates/right-openshell/src/provider_capabilities.rs, crates/right-openshell/src/openshell.rs, crates/bot/src/sandbox_supervisor.rs, crates/right/src/internal_api_providers.rs, docs/architecture/providers.md. Previous issue: config-update could pass on stale rule existence; lifecycle docs stale. Verify fixed. Check for lifetime/closure issues, error messages, rollback behavior, exact endpoint matching, source-guard brittleness, and docs consistency.
Return Strengths, Issues by severity, verification run if any, and 'Ready to merge? Yes | No | With fixes'.
User
Code/docs quality re-review for repo /Users/molt/dev/rightclaw/.worktrees/providers-v2-bulletproof-composition. Do not edit files.
Focus on crates/right/src/internal_api_providers.rs current HEAD, especially built-in create and config-update composition confirmation, rollback behavior, ordered source guards, composed return state, and docs consistency in ARCHITECTURE.md / docs/architecture/providers.md. Previous findings: config-update did not wait; source-shape test only checked substrings. Verify both are fixed or report remaining issues. Return Strengths, Issues by severity, verification run if any, and 'Ready to merge? Yes | No | With fixes'.
User
Spec compliance re-review for repo /Users/molt/dev/rightclaw/.worktrees/providers-v2-bulletproof-composition. Do not edit files.
Review current HEAD after fixes 76bc4c44 and 2dddff2f against Task 10 and the design spec. Specifically verify the prior gap is closed: handle_provider_config_update must call wait_for_provider_composed after ensure_provider_policy_loaded and before replace_provider_in_yaml, and return composed=true only after confirmation. Also verify dashboard built-in create, generic create, and supervisor paths match the documented invariant; docs are not overclaiming; ARCHITECTURE.md remains under 40k.
Return ✅ Spec compliant or concise gaps with file/line refs.
User
Code/docs quality review for repo /Users/molt/dev/rightclaw/.worktrees/providers-v2-bulletproof-composition. Do not edit files.
Review current HEAD, focusing on the new dashboard built-in create confirmation in crates/right/src/internal_api_providers.rs and the Task 10 docs in ARCHITECTURE.md and docs/architecture/providers.md. Check for duplicated rollback risks, error semantics, YAML write ordering, rollback reload behavior, status/composed correctness, source-shape test brittleness, docs overclaiming, ARCHITECTURE.md budget discipline, and consistency with existing generic provider create behavior.
Return Strengths, Issues by severity, verification you ran if any, and 'Ready to merge? Yes | No | With fixes'.
User
Spec compliance review for repo /Users/molt/dev/rightclaw/.worktrees/providers-v2-bulletproof-composition. Do not edit files.
Review current HEAD, especially commits 8937d21b and 76bc4c44, against:
docs/superpowers/specs/2026-06-07-providers-v2-bulletproof-composition-design.md Components 1-5, especially the invariant that every provider attach path guarantees providers_v2 and composition success is directly observed.
Check:
ARCHITECTURE.md Providers section has a concise prescriptive invariant, under 40k budget.
docs/architecture/providers.md describes policy set as reload trigger only, wait_for_provider_composed as active-policy success signal, two v2 funnels, loud backstop, built-in + generic scope, folding removed and legacy strip cleanup-only.
The code now matches the documented invariant for dashboard built-in create as well as generic create and supervisor reconcile.
Any docs drift introduced by the built-in fix.
Return ✅ Spec compliant or concise gaps with file/line refs.
User
Task 10 implementer for repo /Users/molt/dev/rightclaw/.worktrees/providers-v2-bulletproof-composition on branch feat/providers-v2-bulletproof-composition.
You are not alone in the codebase. Do not revert or overwrite edits made by others. Your exclusive write ownership is:
ARCHITECTURE.md
docs/architecture/providers.md
Do not edit code or other docs.
Use the local repo instructions in AGENTS.md already applicable to this worktree: keep ARCHITECTURE.md prescriptive only and under 40k chars; descriptive/provider flow content belongs in docs/architecture/providers.md. This is a docs-only task.
Plan task: docs/superpowers/plans/2026-06-07-providers-v2-bulletproof-composition.md Task 10.
Required content:
In ARCHITECTURE.md ### Providers, add a concise prescriptive invariant:
Every provider attach path MUST guarantee providers_v2_enabled via right_openshell::providers::ensure_v2_enabled.
The funnels are reconcile_for_sandbox (supervisor) and dashboard create/config-update handlers.
Composition success MUST be confirmed with openshell::wait_for_provider_composed, which reads the active policy for the composed _provider_<name> rule, never inferred from policy set --wait.
Applies to built-in and generic providers.
In docs/architecture/providers.md, update the composition/policy interaction section to document:
policy set --wait is a reload trigger only, not the success signal because it can no-op on unchanged policy hash.
wait_for_provider_composed is the success signal after reload; it polls active policy for _provider_<name>.
The two-funnel v2 guarantee: reconcile_for_sandbox for supervisor bring-up/hot-reconcile and dashboard create/config-update handlers.
Loud backstop: a future missed v2-enable times out/fails instead of silently producing upstream 401/CONNECT failures.
Scope covers built-in and generic providers; both rely on OpenShell profile composition.
Return status DONE / DONE_WITH_CONCERNS / BLOCKED, changed files, verification output, and commit SHA.
User
You are the code quality reviewer for Tasks 8-9 in repo /Users/molt/dev/rightclaw/.worktrees/providers-v2-bulletproof-composition. Do not edit files. Review current HEAD commit e1fc0d2c, focusing on crates/right-openshell/tests/ci_openshell_generic_provider.rs and crates/right-openshell/tests/ci_openshell_github.rs. The previous quality finding was that the self-enable test was masked because it restored providers_v2_enabled=true before reload/composition; verify whether that is fixed. Check cleanup safety, panic/restore ordering, exact credential assertion, async borrow correctness, test flakiness, and style. Return Strengths, Issues by severity, and 'Ready to merge? Yes | No | With fixes'.
User
You are the spec compliance reviewer for Tasks 8-9 of docs/superpowers/plans/2026-06-07-providers-v2-bulletproof-composition.md in repo /Users/molt/dev/rightclaw/.worktrees/providers-v2-bulletproof-composition. Do not edit files. Review commit e1fc0d2c (or current HEAD if rewritten) against only Tasks 8 and 9 of that plan. Check that the generic provider live test asserts provider composition, that the self-enable test proves reconcile_for_sandbox self-enables providers_v2 without being masked by a manual restore, and that the GitHub live test asserts built-in right-github composition. Also account for the repo fact that these ignored test targets require --features test-support for compilation. Return: ✅ Spec compliant or a concise list of spec gaps with file/line references.
User
You are a Senior Code Reviewer reviewing amended Tasks 8-9 in /Users/molt/dev/rightclaw/.worktrees/providers-v2-bulletproof-composition.
Do not modify files. Report only.
What Was Implemented
Live ignored OpenShell tests now assert provider composition:
Generic provider header substitution test waits for active-policy composition.
Fresh-gateway test forces providers_v2_enabled false immediately before reconcile_for_sandbox, restores it true immediately after reconcile returns, then asserts composition and substitution.
GitHub provider live test waits for built-in provider composition before gh api.
Existing generic header substitution test calls wait_for_provider_composed after policy reload and before curl/placeholder usage.
New ignored test ci_openshell_reconcile_self_enables_v2_on_fresh_gateway forces providers_v2 false, drives reconcile_for_sandbox, reloads policy, waits for composition and placeholder, then asserts substitution.
Helper set_providers_v2 uses UpdateConfig with PROVIDERS_V2_ENABLED_KEY.
After prior review feedback, the false flag should be set immediately before reconcile and restored true immediately after reconcile returns, before later assertions.
Existing ci_openshell_generic_profile_substitutes_custom_header should call right_openshell::openshell::wait_for_provider_composed(&mut client, sandbox.name(), &provider_name).await.expect("provider composed into active policy") after ensure_provider_policy_loaded and before curl/placeholder usage.
Add ignored test ci_openshell_reconcile_self_enables_v2_on_fresh_gateway with ignore marker ci-openshell: live sandbox + gateway. It must force providers_v2 false, create provider/profile/sandbox, call reconcile_for_sandbox, reload policy, wait for composition, wait for placeholder, then assert substitution succeeds.
Add helper to set gateway-global providers_v2 setting false/true using UpdateConfig and PROVIDERS_V2_ENABLED_KEY.
Existing ci_openshell_github_gh_api_user_succeeds should assert wait_for_provider_composed after ensure_provider_policy_loaded and before the live gh api command.
Commit under review: ed90079e.
Verification note:
Exact plan commands without features failed because these test targets require required-features = ["test-support"].
Worker reported compile-only passes with --features test-support for both test targets.
Ignored live tests were not run locally.
CRITICAL: Do Not Trust the Report
Read actual code/diff and compare to requirements. Report exactly one of:
✅ Spec compliant if everything matches.
❌ Issues found: with specific missing/extra items and file:line references.
User
You are implementing Tasks 8-9: live integration test compile updates for provider composition.
Worktree: /Users/molt/dev/rightclaw/.worktrees/providers-v2-bulletproof-composition
Branch: feat/providers-v2-bulletproof-composition
Current base before task: 0c3fecf0
You are not alone in the codebase. Do not revert or overwrite edits made by others. Limit your write set to:
ensure_v2_for_mutation(&mut OpenShellClient) helper maps ensure_v2_enabled errors to hard ProviderApiError::Gateway(format!("{e:#}")).
Helper is called immediately after client open in built-in create, generic create, generic config update.
Generic create confirms composition after successful policy reload and before YAML append; failure best-effort detaches/deletes, reloads after rollback, returns hard Gateway error.
Backend ProviderView includes serialized composed: bool; all constructors populate it.
handle_provider_list reads active policy once, degrades composition-state read errors/no payload to default false but logs the unavailable state, uses entry.name for provider_is_composed, and preserves existing per-row provider lookup status behavior.
Frontend type includes composed; Providers row visibly renders composed/not-composed independently from health status.
Composition label must derive from provider.composed itself, not hide true when provider health status is degraded.
Final amended commit under review: 0c3fecf0.
Verification after final amend:
devenv shell -- cargo test -p right internal_api_providers passed: 48 tests.
devenv shell -- npm --prefix crates/right-dashboard/frontend run typecheck passed.
Read actual code/diff and compare to requirements. Report exactly one of:
✅ Spec compliant if everything matches.
❌ Issues found: with specific missing/extra items and file:line references.
User
You are a Senior Code Reviewer reviewing amended grouped Tasks 5-7 in /Users/molt/dev/rightclaw/.worktrees/providers-v2-bulletproof-composition.
Do not modify files. Report only.
What Was Implemented
Grouped dashboard work:
Backend provider dashboard API now ensures v2 for create/config-update mutation paths.
Generic create confirms composition after reload and rolls back on failure.
Provider views include composed state.
Frontend provider row types and rendering now show composed/not-composed as a separate status pill.
Requirements / Plan
Plan file: docs/superpowers/plans/2026-06-07-providers-v2-bulletproof-composition.md, Tasks 5-7.
Core requirements:
ensure_v2_for_mutation helper calls ensure_v2_enabled and maps errors to hard gateway errors.
Helper called after open_openshell_client in built-in create, generic create, generic config update.
Generic create calls wait_for_provider_composed after policy reload and before YAML append; on failure best-effort detach/delete, reload after rollback, return Gateway error.
ProviderView includes serialized composed bool and all constructors populate it.
List fetches active policy once, degrades composition fetch errors to default/false, and uses gateway provider name to compute row composition; existing provider lookup errors remain as row status.
Add ensure_v2_for_mutation(&mut OpenShellClient) helper mapping ensure_v2_enabled failure to ProviderApiError::Gateway(format!("{e:#}")).
Call it after opening client in built-in create, generic create, generic config update.
Task 6 requirements
In generic create, after successful ensure_provider_policy_loaded and before YAML append, call wait_for_provider_composed.
On failure, best-effort detach + delete, run ensure_provider_policy_loaded_after_rollback, return hard Gateway error.
Task 7 requirements
Add serialized ProviderView.composed: bool and populate all backend constructors.
handle_provider_list fetches active policy once, degrades active-policy fetch errors/no payload to default false, uses gateway provider name (entry.name) for provider_is_composed.
Existing per-row get_provider status behavior is preserved.
Operator-visible dashboard should surface the composed/not-composed state; amendment updates frontend type and row rendering.
Amended commit under review: 351c61ab.
Verification after amendment:
devenv shell -- cargo test -p right internal_api_providers passed: 48 tests.
devenv shell -- npm --prefix crates/right-dashboard/frontend run typecheck passed.
Read actual code/diff and compare to requirements. Report exactly one of:
✅ Spec compliant if everything matches.
❌ Issues found: with specific missing/extra items and file:line references.
User
You are a Senior Code Reviewer reviewing grouped Tasks 5-7 in /Users/molt/dev/rightclaw/.worktrees/providers-v2-bulletproof-composition.
Do not modify files. Report only.
What Was Implemented
Tasks 5-7 updated the provider dashboard API:
v2 enabled for create/config-update mutations.
generic create confirms composition after reload and rolls back on timeout/error.
provider list surfaces composed state from active policy.
Requirements / Plan
Plan file: docs/superpowers/plans/2026-06-07-providers-v2-bulletproof-composition.md, Tasks 5-7.
Core requirements:
ensure_v2_for_mutation helper calls right_openshell::providers::ensure_v2_enabled and maps errors to hard gateway errors.
Helper called after open_openshell_client in built-in create, generic create, generic config update.
Generic create calls wait_for_provider_composed after policy reload and before YAML append; on failure best-effort detach/delete, reload after rollback, return gateway error.
ProviderView includes serialized composed bool and all constructors populate it.
List fetches active policy once, degrades composition fetch errors to default/false, and uses gateway provider name to compute row composition; existing per-row provider status behavior remains.
devenv shell -- cargo test -p right internal_api_providers passed: 48 tests.
Spec compliance reviewer returned ✅ Spec compliant.
What to Check
Correct rollback/error behavior in generic create. No swallowed hard errors except intentional best-effort rollback.
Dashboard create/update ordering is correct: v2 before attach/recompose.
composed field is honest: true only after direct confirmation; false where unknown.
List behavior: active policy fetch failure does not abort list, but provider lookup errors are still represented as before.
Serialization/backward compatibility concerns.
Code quality, test quality, scope.
Return:
Strengths
Issues (Critical/Important/Minor)
Recommendations
Assessment with Ready to merge? Yes | No | With fixes.
User
You are reviewing spec compliance for grouped Tasks 5-7 in /Users/molt/dev/rightclaw/.worktrees/providers-v2-bulletproof-composition.
Do not modify files. Report only.
What Was Requested
Tasks 5-7 all modify crates/right/src/internal_api_providers.rs.
Task 5 requirements
Add helper near open_openshell_client:
ensure_v2_for_mutation(client: &mut OpenShellClient) -> Result<(), ProviderApiError> that calls right_openshell::providers::ensure_v2_enabled(client).await and maps errors to ProviderApiError::Gateway(format!("{e:#}")).
Call the helper immediately after opening the client in:
built-in branch of handle_provider_create, before create_provider.
create_generic_provider, before ensure_profiles/create_provider.
handle_provider_config_update, before snapshot/profile/update/reload sequence.
Task 6 requirements
In create_generic_provider, after successful ensure_provider_policy_loaded and before append_provider_to_yaml, call right_openshell::openshell::wait_for_provider_composed(&mut client, &sandbox_name, &name).await.
On failure, follow same recovery shape as failed reload: best-effort detach + delete, run ensure_provider_policy_loaded_after_rollback, return hard ProviderApiError::Gateway(format!("{compose_err:#}")).
Task 7 requirements
Add composed: bool field to ProviderView with #[serde(default)] and doc saying it means active-policy composition state.
Populate every ProviderView construction.
In handle_provider_list, fetch active policy once after resolving/opening client, degrade fetch errors/no payload to default policy, and set per-row composed using right_openshell::provider_capabilities::provider_is_composed(&active_policy, &entry.name).
Preserve existing per-row get_provider error/status behavior. Only active policy fetch should degrade to composed: false.
For responses without a direct policy signal, do not claim true. Generic create may return composed: true after successful confirmation.
Commit under review: 3b9fcfc8.
Verification reported:
devenv shell -- cargo check -p right passed.
devenv shell -- cargo test -p right internal_api_providers passed: 48 tests.
Worker also ran full workspace test successfully, but this spec review should inspect code.
CRITICAL: Do Not Trust the Report
Read actual code/diff and compare to requirements. Report exactly one of:
✅ Spec compliant if everything matches.
❌ Issues found: with specific missing/extra items and file:line references.
User
You are implementing Tasks 5-7 from the providers-v2 bulletproof composition plan.
Worktree: /Users/molt/dev/rightclaw/.worktrees/providers-v2-bulletproof-composition
Branch: feat/providers-v2-bulletproof-composition
Current base before this grouped dashboard task: 9461bae3
You are not alone in the codebase. Do not revert or overwrite edits made by others. Limit your write set to:
crates/right/src/internal_api_providers.rs
Repository rules:
Rust edition 2024.
Run commands as devenv shell -- <command> from the worktree.
Use apply_patch for manual edits if available.
Keep edits ASCII.
Preserve existing error propagation and rollback style; use format!("{e:#}") for error chains.
Do not touch unrelated code.
Because Tasks 5-7 all touch one large file, implement and commit them together with one Conventional Commit if clean. Use commit message:
feat(dashboard): ensure and surface provider composition state
Task 5: Guarantee v2 in dashboard create + config-update
Add a helper near open_openshell_client:
rust
/// Ensure providers_v2 is enabled before a dashboard mutation that attaches or
/// recomposes a provider. The dashboard is an explicit user action, so a failure
/// here is a hard, surfaced error: the operation cannot work with the flag off.
async fn ensure_v2_for_mutation(client: &mut OpenShellClient) -> Result<(), ProviderApiError> {
right_openshell::providers::ensure_v2_enabled(client)
.await
.map_err(|e| ProviderApiError::Gateway(format!("{e:#}")))
}
Use the local type OpenShellClient = ... alias already defined in this file.
Call ensure_v2_for_mutation(&mut client).await?; immediately after opening the client in:
handle_provider_create built-in path: after let mut client = open_openshell_client().await?; and before create_provider.
create_generic_provider: after and before /.
User
You are a Senior Code Reviewer reviewing Task 4 in /Users/molt/dev/rightclaw/.worktrees/providers-v2-bulletproof-composition.
Do not modify files. Report only.
What Was Implemented
Task 4 added provider composition confirmation after policy reload in supervisor bring-up and hot-reconcile paths.
Requirements / Plan
Plan task: docs/superpowers/plans/2026-06-07-providers-v2-bulletproof-composition.md, Task 4.
Core requirements:
In bring_up_sandbox, after ensure_provider_policy_loaded succeeds and before logging loaded, call wait_for_provider_composed for declared providers not in report.missing, using grpc_client and startup contextual error.
In hot_reconcile_providers, after ensure_provider_policy_loaded succeeds and before Ok(()), call wait_for_provider_composed for declared providers not in report.missing, using client and hot-reconcile contextual error.
Worker reported devenv shell -- cargo check -p right-bot passed. The plan’s -p bot was stale.
Spec compliance reviewer returned ✅ Spec compliant.
What to Check
Correct error propagation and retry semantics: bring-up fatal, hot-reconcile returns Err for bounded backoff.
No confirmation for missing providers.
No borrow/lifetime or client-use issues.
No false confirmation outside reload-needed branch.
Scope and readability.
Return:
Strengths
Issues (Critical/Important/Minor)
Recommendations
Assessment with Ready to merge? Yes | No | With fixes.
User
You are reviewing spec compliance for Task 4 in /Users/molt/dev/rightclaw/.worktrees/providers-v2-bulletproof-composition.
Do not modify files. Report only.
What Was Requested
Task 4: Confirm composition after reload in the supervisor.
File:
crates/bot/src/sandbox_supervisor.rs
Requirements:
In bring_up_sandbox, inside the existing if provider_policy_reload_needed(...) block, immediately after ensure_provider_policy_loaded(&sandbox, &policy_path)...? succeeds and before the "provider-profile composition loaded" tracing info, loop over declared.iter().filter(|d| !report.missing.contains(*d)) and call right_openshell::openshell::wait_for_provider_composed(&mut grpc_client, &sandbox, name).await, mapping errors to miette!("provider composition not confirmed during startup reconcile: {e:#}") or equivalent contextual message.
In hot_reconcile_providers, inside the existing if provider_policy_reload_needed(...) block, immediately after ensure_provider_policy_loaded(resolved_sandbox, &policy_path)...?, loop over the same non-missing declared providers and call wait_for_provider_composed(&mut client, resolved_sandbox, name).await, mapping errors to miette!("provider composition not confirmed: {e:#}") or equivalent contextual message.
Only confirm after a reload trigger succeeds.
Do not confirm missing providers.
Keep scope narrow to the supervisor file.
Commit under review: 9461bae3.
Verification note: Plan command said cargo check -p bot, but actual package is right-bot. Worker reported devenv shell -- cargo check -p right-bot passed.
CRITICAL: Do Not Trust the Report
Read actual code/diff and compare to requirements. Report exactly one of:
✅ Spec compliant if everything matches.
❌ Issues found: with specific missing/extra items and file:line references.
User
You are implementing Task 4: Confirm composition after reload in the supervisor.
Worktree: /Users/molt/dev/rightclaw/.worktrees/providers-v2-bulletproof-composition
Branch: feat/providers-v2-bulletproof-composition
Current base before task: 4a44a00f
You are not alone in the codebase. Do not revert or overwrite edits made by others. Limit your write set to:
crates/bot/src/sandbox_supervisor.rs
Repository rules:
Rust edition 2024.
Run commands as devenv shell -- <command> from the worktree.
Use apply_patch for manual edits if available.
Keep edits ASCII.
Verify with compile command below.
Commit this task with the exact message below.
Task Description
After ensure_provider_policy_loaded triggers provider-profile composition reload, confirm each declared, non-missing provider actually composed by calling right_openshell::openshell::wait_for_provider_composed.
Files:
Modify: crates/bot/src/sandbox_supervisor.rs
Step 1: Add confirmation in bring_up_sandbox
In bring_up_sandbox, inside the if provider_policy_reload_needed(&declared, &report, &profile_outcomes) block, immediately after:
and before the tracing info "provider-profile composition loaded", add:
rust
for name in declared.iter().filter(|d| !report.missing.contains(*d)) {
right_openshell::openshell::wait_for_provider_composed(
&mut grpc_client,
&sandbox,
name,
)
.await
.map_err(|e| {
miette::miette!("provider composition not confirmed during startup reconcile: {e:#}")
})?;
}
User
You are a Senior Code Reviewer reviewing amended Task 3 in /Users/molt/dev/rightclaw/.worktrees/providers-v2-bulletproof-composition.
Do not modify files. Report only.
What Was Implemented
Task 3 updated reconcile_for_sandbox to ensure provider v2 before reading sandbox attachments when declarations are non-empty, and added regression tests for both non-empty and empty declared behavior.
Requirements / Plan
Plan task: docs/superpowers/plans/2026-06-07-providers-v2-bulletproof-composition.md, Task 3.
Core requirements:
In providers.rs, insert at the top of reconcile_for_sandbox, before list_attached: if declared is non-empty, call ensure_v2_enabled(client).await?.
Skip the call when declared is empty.
Add a targeted test where mock_update_config returns v2-boom and reconcile with a declared provider returns that error before list/attach.
Keep scope narrow.
The amended commit also adds a regression test for empty-declared skip behavior and tightened doc wording after prior review feedback.
Add a regression test proving reconcile_for_sandbox invokes ensure_v2_enabled before list_attached/attach when declared is non-empty. Test should configure mock_update_config to return internal("v2-boom") and assert reconcile returns ProviderError::Grpc containing v2-boom for declared provider agent-x.
Add implementation at the very top of reconcile_for_sandbox, before list_attached, that calls ensure_v2_enabled(client).await? only when !declared.is_empty().
Preserve detach-only empty-declared path: skip v2 enable when no providers are declared.
Keep scope narrow; no unrelated refactors.
Amended commit under review: 4a44a00f.
Additional context: A prior quality review found the doc sentence overbroad for empty declarations. The commit was amended to tighten wording and add reconcile_skips_v2_when_nothing_declared.
Read actual code/diff and compare to requirements. Report exactly one of:
✅ Spec compliant if everything matches.
❌ Issues found: with specific missing/extra items and file:line references.
User
You are a Senior Code Reviewer reviewing Task 3 in /Users/molt/dev/rightclaw/.worktrees/providers-v2-bulletproof-composition.
Do not modify files. Report only.
What Was Implemented
Task 3 updated reconcile_for_sandbox to call ensure_v2_enabled before reading sandbox attachments whenever providers are declared, and added a regression test proving the call happens before list_attached.
Requirements / Plan
Plan task: docs/superpowers/plans/2026-06-07-providers-v2-bulletproof-composition.md, Task 3.
Core requirements:
In providers.rs, insert at the top of reconcile_for_sandbox, before list_attached: if declared is non-empty, call ensure_v2_enabled(client).await?.
Skip the call when declared is empty.
Add a targeted test in providers_tests.rs where mock_update_config returns v2-boom and reconcile with a declared provider returns that error before touching list/attach.
Add a regression test proving reconcile_for_sandbox invokes ensure_v2_enabled before list_attached/attach when declared is non-empty. The test should configure mock_update_config to return internal("v2-boom") and assert reconcile returns ProviderError::Grpc containing v2-boom for declared provider agent-x.
Add implementation at the very top of reconcile_for_sandbox, before list_attached, that calls ensure_v2_enabled(client).await? only when !declared.is_empty().
Preserve the detach-only empty-declared path: skip v2 enable when no providers are declared.
Keep scope narrow; no unrelated refactors.
Commit under review: 0946ae3a.
Implementer Notes
The implementer used .err().expect(...) instead of .unwrap_err() because ReconcileReport does not implement Debug; this is acceptable if behavior remains identical.
Verification evidence:
RED reported by worker: targeted test failed behaviorally before implementation by reaching unimplemented list_sandbox_providers first.
GREEN rerun by controller after amend: devenv shell -- cargo test -p right-openshell reconcile_ensures_v2 passed: 1 test passed.
CRITICAL: Do Not Trust the Report
Read the actual code/diff and compare to requirements. Report exactly one of:
✅ Spec compliant if everything matches.
❌ Issues found: with specific missing/extra items and file:line references.
User
You are implementing Task 3: Guarantee providers_v2_enabled inside reconcile_for_sandbox.
Worktree: /Users/molt/dev/rightclaw/.worktrees/providers-v2-bulletproof-composition
Branch: feat/providers-v2-bulletproof-composition
Current base before task: f5474163
You are not alone in the codebase. Do not revert or overwrite edits made by others. Limit your write set to:
crates/right-openshell/src/providers.rs
crates/right-openshell/src/providers_tests.rs
Repository rules:
Rust edition 2024.
Run commands as devenv shell -- <command> from the worktree.
reconcile_for_sandbox is the funnel for supervisor provider attach paths. It must call ensure_v2_enabled(client).await? at the very top when declared is non-empty, before list_attached, so provider composition cannot be silently skipped. It must skip v2 enable when declared is empty.
Step 1: Append this failing test to providers_tests.rs:
rust
#[tokio::test]
async fn reconcile_ensures_v2_before_touching_providers_when_declared() {
// update_config (ensure_v2) errors -> reconcile must surface that error,
// proving ensure_v2 runs at the very top before list/attach.
let mock = MockOpenShell {
mock_update_config: Some(Box::new(|_| Err(tonic::Status::internal("v2-boom")))),
..Default::default()
};
let (addr, _shutdown) = start_mock_server(mock).await;
let mut client = mock_client(addr).await;
let err = reconcile_for_sandbox(&mut client, "sbx", "agent", &["agent-x".to_string()])
.await
.unwrap_err();
match err {
ProviderError::Grpc(msg) => assert!(msg.contains("v2-boom"), "{msg}"),
other => panic!("expected Grpc from ensure_v2, got: {other:?}"),
}
}
User
You are a Senior Code Reviewer reviewing Task 2 in /Users/molt/dev/rightclaw/.worktrees/providers-v2-bulletproof-composition.
Do not modify files. Report only.
What Was Implemented
Task 2 added wait_for_provider_composed, a public polling helper in openshell.rs that waits for a provider's composed _provider_<name> rule to appear in the active sandbox policy.
Requirements / Plan
Plan task: docs/superpowers/plans/2026-06-07-providers-v2-bulletproof-composition.md, Task 2.
Core requirements:
Add PROVIDER_COMPOSE_POLL and PROVIDER_COMPOSE_TIMEOUT constants.
Concern: no behavioral unit test, expected by plan because mock server lacks get_sandbox_policy_status; live tests cover downstream.
CRITICAL: Do Not Trust the Report
Read actual code/diff and compare to requirements. Report exactly one of:
✅ Spec compliant if everything matches.
❌ Issues found: with specific missing/extra items and file:line references.
User
You are implementing Task 2: wait_for_provider_composed polling helper.
Worktree: /Users/molt/dev/rightclaw/.worktrees/providers-v2-bulletproof-composition
Branch: feat/providers-v2-bulletproof-composition
Current base before task: ca3005a0
You are not alone in the codebase. Do not revert or overwrite edits made by others. Limit your write set to:
crates/right-openshell/src/openshell.rs
Repository rules:
Rust edition 2024.
Run project commands as devenv shell -- <command> from the worktree.
Use apply_patch for manual edits if available.
Verify with the requested compile command.
Commit the task using the exact Conventional Commit message below.
Keep edits ASCII. If the plan snippet contains em dash characters, convert them to ASCII punctuation in comments/errors.
Task Description
Add wait_for_provider_composed near get_active_policy in crates/right-openshell/src/openshell.rs.
Existing context:
openshell.rs already imports std::time::Duration; add Instant if needed by changing it to use std::time::{Duration, Instant};.
get_active_policy(client, sandbox_name) already exists near line 2060 and returns miette::Result<Option<SandboxPolicy>>.
You are a Senior Code Reviewer reviewing Task 1 in /Users/molt/dev/rightclaw/.worktrees/providers-v2-bulletproof-composition.
You are not alone in the codebase. Do not modify files. Report only.
What Was Implemented
Task 1 added provider_is_composed, a public thin predicate over active sandbox policy composition, plus unit tests.
Requirements / Plan
Plan task: docs/superpowers/plans/2026-06-07-providers-v2-bulletproof-composition.md, Task 1.
Requirements:
Add pub fn provider_is_composed(policy: &SandboxPolicy, provider_name: &str) -> bool in crates/right-openshell/src/provider_capabilities.rs near rule_for_provider, implemented as rule_for_provider(policy, provider_name).is_some().
Add tests in crates/right-openshell/src/provider_capabilities_tests.rs for true when _provider_right_example rule is present for provider right-example, and false on empty policy.
provider_is_composed_true_when_rule_present: builds a policy with _provider_right_example and asserts crate::provider_capabilities::provider_is_composed(&policy, "right-example") is true.
provider_is_composed_false_on_empty_policy: default SandboxPolicy, same provider name, asserts false.
Implement pub fn provider_is_composed(policy: &SandboxPolicy, provider_name: &str) -> bool directly after private rule_for_provider, as a thin wrapper returning rule_for_provider(policy, provider_name).is_some().
No extra behavior beyond exposing the existing direct composition signal.
Task commit: ca3005a0.
What Implementer Claims They Built
The code has been committed as ca3005a0 with message feat(providers): provider_is_composed predicate over active policy. Targeted test evidence was independently verified by controller:
Without the predicate, devenv shell -- cargo test -p right-openshell provider_is_composed failed with E0425 for missing function.
With the predicate restored, the same command passed: 2 tests passed.
CRITICAL: Do Not Trust the Report
Read the actual code in the worktree and compare implementation to requirements line by line. Do not run broad tests unless needed; this is a read-only spec review.
Report exactly one of:
✅ Spec compliant if everything matches after code inspection.
❌ Issues found: with specific missing/extra items and file:line references.
User
continue
User
You are implementing Task 1: Pure provider_is_composed predicate.
Worktree: /Users/molt/dev/rightclaw/.worktrees/providers-v2-bulletproof-composition
Branch: feat/providers-v2-bulletproof-composition
Base SHA before task: 57d5ee7ce358b2f70a0639f64fb6654ce6b55f8b
You are not alone in the codebase. Do not revert or overwrite edits made by others. Limit your write set to:
Step 1: Append these tests to provider_capabilities_tests.rs, reusing existing policy_with helper:
rust
#[test]
fn provider_is_composed_true_when_rule_present() {
// Provider gateway name `right-example` composes under rule key
// `_provider_right_example` (the `_provider_` prefix + sanitized name).
let policy = policy_with("_provider_right_example", &["**"], &["api.example.com"]);
assert!(crate::provider_capabilities::provider_is_composed(
&policy,
"right-example"
));
}
#[test]
fn provider_is_composed_false_on_empty_policy() {
let policy = crate::openshell_proto::openshell::sandbox::v1::SandboxPolicy::default();
assert!(!crate::provider_capabilities::provider_is_composed(
&policy,
"right-example"
));
}
User
use subagent-driven develkopment for docs/superpowers/plans/2026-06-07-providers-v2-bulletproof-composition.md in a worktree then run $cc-review then merge to local master then push
User
AGENTS.md instructions for /Users/molt/dev/rightclaw
Think deeply, respond concisely. No filler, no summaries, no restating what I said. Be direct and assertive — no flattery, no "great question", no eager agreement, never say "You're right". Challenge my assumptions and point out flaws. Be equally critical of your own reasoning — catch your mistakes before I do.
When you show me code snippets, always say which file they are from.
Development practices
Prefer simple, maintainable solutions. Avoid both overengineering and half-baked hacks.
State assumptions explicitly. If multiple interpretations exist, present them before picking one.
For multi-step tasks, state a brief plan with verification criteria before starting. Don't claim done without running the checks.
When editing existing code: remove only imports/variables/functions that YOUR changes made unused. Don't touch pre-existing dead code — mention it, don't delete it.
For financial code: prioritize accuracy and reliability over simplicity.
ALWAYS read and understand relevant files before proposing edits. Do not speculate about code you have not inspected.
TDD for behavior changes: write the narrowest failing test before fixing a bug or implementing a feature. For bugs — regression test first, verify it fails, then fix.
Test cadence: do not run tests at every small step. Run a baseline check when starting work in a new worktree, run targeted tests/checks after feature development or meaningful changes, and prefer targeted tests over full workspace tests while iterating.
Final verification: before declaring work complete, run the full workspace test/check/build suite. This is mandatory in each worktree you touched.
Try not to create files with > 900 lines. If > 50% of code is tests, extract them to separate files.
Before writing new code, check if similar logic already exists in the codebase. Extract shared logic rather than duplicating it across files. This applies especially during multi-step plan execution — review what prior steps produced.
Auto-use context7 MCP for library docs, setup, and code generation — don't wait for me to ask.
Rust
Edition 2024 always.
Load rust-dev:rust-dev skill (via Skill tool, NOT Agent) before writing Rust yourself. Delegate: rust-dev:rust-coder for implementation, rust-dev:rust-builder for build/clippy/check, rust-dev:review-rust-code for reviews.
After significant changes: run review-rust-code subagent, issues → TODOs, fix one by one.
Spec compliance re-review for repo /Users/molt/dev/rightclaw/.worktrees/providers-v2-bulletproof-composition at current HEAD a1e4f675. Do not edit files.
Review the completed providers-v2 composition work against docs/superpowers/plans/2026-06-07-providers-v2-bulletproof-composition.md and docs/superpowers/specs/2026-06-07-providers-v2-bulletproof-composition-design.md. Focus on the prior stale-rule issue: generic create/config-update and supervisor generic reconciles must not accept a stale pre-update _provider_<name> rule; they should require expected endpoint host/path content. Built-ins can use rule-presence wait. Check docs reflect this and ARCHITECTURE.md remains under 40k.
Return ✅ Spec compliant or concise gaps with file/line refs. No full test suite required.
Assistant
Using superpowers:using-superpowers first, then I’ll do a read-only compliance pass against the plan/spec and the current worktree. No edits.
Assistant
Plan: verify HEAD and doc constraints, read the spec/plan language around provider rules, then trace the generic create/update and supervisor reconcile paths for endpoint host/path matching. Compliance criteria are narrow: stale _provider_<name> presence alone must not satisfy generic paths, built-ins may still wait on presence, and ARCHITECTURE.md must be below 40k chars.
Assistant
The high-level plan/spec still contain older “rule presence” language in several places, so I’m checking whether there is a later amendment in those docs and whether the code enforces endpoint-specific matching on the generic paths.
Assistant
The code has a stricter endpoint-aware helper and the supervisor distinguishes built-ins from generic providers. I’m reading the exact call sites now because the likely compliance boundary is whether generic config-update also uses that stricter helper after reload.
Assistant
I found endpoint-aware unit coverage for the core predicate and marker-order tests for dashboard create/update. I’m checking the concrete handler bodies now; if the docs still say only rule presence for generic paths, that’s a documentation gap even if code is correct.
Assistant
The satellite architecture doc has the stale-rule clarification, but ARCHITECTURE.md itself still states the broader rule-presence helper only. I’m checking whether the plan/spec files themselves were amended; the user asked specifically to review against those docs.
Assistant
Code-side, the stale-rule protection is present in the generic paths I checked. The remaining issue is documentation consistency: the exact plan/spec and ARCHITECTURE.md still describe composition success as _provider_ rule presence, while docs/architecture/providers.md has the stricter generic exception.
Assistant
I’m running only targeted verification for the reviewed invariants: the endpoint-aware predicate, the dashboard marker-order tests, and the supervisor generic-vs-built-in expectation tests. No workspace suite.
Assistant
One targeted command used the wrong package id for the bot crate, and one dashboard filter matched zero tests. I’m correcting those instead of treating the partial run as evidence.
Assistant
The missing filters are identified: the right crate test is generic_create_confirms_endpoint_composition_before_yaml_write, and the bot package is right-bot. I’m rerunning those two targeted checks.
Assistant
Targeted checks pass for the code paths under review. I’m doing one final read-only status check so the final answer can distinguish code compliance from documentation gaps.
Assistant
Concise gaps:
docs/superpowers/plans/2026-06-07-providers-v2-bulletproof-composition.md still describes success as _provider_<name> rule presence after each reload, with no generic endpoint host/path requirement. Same stale language recurs at line 583.
docs/superpowers/specs/2026-06-07-providers-v2-bulletproof-composition-design.md defines wait_for_provider_composed as rule-presence only and does not capture the stale-rule correction for generic create/config-update/supervisor generic reconciles.
ARCHITECTURE.md is under budget at 37,595 chars, but its invariant still says composition success is wait_for_provider_composed rule presence and “applies to built-in and generic providers.” That should distinguish built-ins from generic endpoint-aware confirmation. The satellite doc does have the corrected wording at docs/architecture/providers.md.
Code-side stale-rule handling checked out: generic create, config-update, and supervisor generic waits use endpoint-aware confirmation; built-ins use rule presence. Targeted tests passed; no full suite run. Worktree status is clean at a1e4f675.
handle_provider_config_update: after let mut client = open_openshell_client().await?; and before snapshot/profile/update/reload sequence.
Task 6: Confirm composition after generic-create reload
In create_generic_provider, after successful ensure_provider_policy_loaded(&sandbox_name, &policy_path).await and before append_provider_to_yaml, call:
rust
if let Err(compose_err) =
right_openshell::openshell::wait_for_provider_composed(&mut client, &sandbox_name, &name).await
{
let _ = right_openshell::providers::detach_from_sandbox(&mut client, &sandbox_name, &name).await;
let _ = right_openshell::providers::delete_provider(&mut client, &name).await;
ensure_provider_policy_loaded_after_rollback(
&name,
&sandbox_name,
&policy_path,
format!("{compose_err:#}"),
"composition not confirmed",
)
.await;
return Err(ProviderApiError::Gateway(format!("{compose_err:#}")));
}
You may improve this to match local rollback logging style if concise, but preserve semantics:
same recovery shape as failed reload: best-effort detach + delete, reload after rollback, return hard Gateway error.
This confirmation is for generic create after reload only.
Task 7: Surface composed state in provider list
Add a composed: bool field to ProviderView:
rust
/// Whether this provider's endpoints are composed into the sandbox's active
/// policy. `false` means attached but not substituting.
#[serde(default)]
pub composed: bool,
Populate it in every ProviderView construction in this file.
For list handler specifically:
It already opens an OpenShell client unconditionally and uses it for get_provider per row.
After resolving/opening client and before the loop, fetch active policy once using:
rust
let sandbox_name = sandbox.name.clone().unwrap_or_else(|| req.agent.clone());
let active_policy = right_openshell::openshell::get_active_policy(&mut client, &sandbox_name)
.await
.ok()
.flatten()
.unwrap_or_default();
Use the gateway provider name, entry.name, when setting row composition:
rust
let composed = right_openshell::provider_capabilities::provider_is_composed(
&active_policy,
&entry.name,
);
Preserve existing get_provider per-row error/status behavior. Only the active-policy fetch should degrade to composed: false on gateway/status errors.
For create/update/rotate responses where no policy is fetched in that handler, set a reasonable value:
Built-in create: no reload/confirmation in this task; use composed: false unless you have a direct policy signal.
Generic create after successful wait_for_provider_composed: use composed: true.
Config update after successful reload: if you choose not to confirm there (plan Task 6 only confirms generic-create), use composed: false unless you add direct confirmation and preserve rollback semantics. Do not silently claim true without checking.
Rotate response: use composed: false.
Also update any tests/snapshots that require the new field.
Verification
Run these targeted commands:
devenv shell -- cargo check -p right
devenv shell -- cargo test -p right internal_api_providers
If the crate/package name differs, inspect Cargo.toml and use the actual package name; report the adjustment.
Commit
Commit only crates/right/src/internal_api_providers.rs with:
git add crates/right/src/internal_api_providers.rsgit commit -m "feat(dashboard): ensure and surface provider composition state"
for name in declared.iter().filter(|d| !report.missing.contains(*d)) {
right_openshell::openshell::wait_for_provider_composed(&mut client, resolved_sandbox, name)
.await
.map_err(|e| miette::miette!("provider composition not confirmed: {e:#}"))?;
}
You may format line breaks to satisfy rustfmt. Preserve semantics:
Adjust imports if needed. providers_tests.rs currently imports provider functions; include reconcile_for_sandbox if it is not already imported.
Step 2: Run devenv shell -- cargo test -p right-openshell reconcile_ensures_v2 and confirm it fails before implementation.
Step 3: In crates/right-openshell/src/providers.rs, insert at the very top of reconcile_for_sandbox, before let attached = list_attached(...):
rust
// Provider composition is gated by the gateway-global providers_v2_enabled
// flag (default false on fresh gateways). Guarantee it before any attach so
// composition is not silently skipped. Skip when nothing is declared: a
// detach-only reconcile needs no composition and must not fail on this.
if !declared.is_empty() {
ensure_v2_enabled(client).await?;
}
Step 4: Run devenv shell -- cargo test -p right-openshell reconcile_ensures_v2 and confirm it passes.
Step 5: Commit:
git add crates/right-openshell/src/providers.rs crates/right-openshell/src/providers_tests.rsgit commit -m "feat(providers): ensure_v2_enabled at top of reconcile_for_sandbox when declared"
Context
Existing reconcile_for_sandbox currently begins with let attached = list_attached(client, sandbox_name).await?;. The new call must happen before that when declared is non-empty. This changes documented behavior slightly: non-empty declared reconcile can now fail before list if the global flag upsert fails, which is the intended fail-fast behavior.
/// Poll interval while waiting for provider-profile composition to appear.
const PROVIDER_COMPOSE_POLL: Duration = Duration::from_millis(250);
/// Upper bound for composition to appear after a policy reload. Composition is
/// sub-second empirically (see docs/architecture/providers.md); the margin
/// tolerates a cold gateway. Tune against the live container if flaky.
const PROVIDER_COMPOSE_TIMEOUT: Duration = Duration::from_secs(10);
/// Wait until `provider_name` is composed into `sandbox_name`'s active policy.
///
/// This is the success signal for provider composition: it reads the composed
/// `_provider_<name>` rule directly via `get_active_policy`, rather than trusting
/// the `policy set --wait` return (which no-ops on an unchanged policy hash).
/// A timeout here means the provider attached but never composed: the loud
/// signal that `providers_v2_enabled` is off on the gateway, or that composition
/// otherwise failed. Errors propagate (FAIL FAST).
pub async fn wait_for_provider_composed(
client: &mut OpenShellClient<Channel>,
sandbox_name: &str,
provider_name: &str,
) -> miette::Result<()> {
let deadline = Instant::now() + PROVIDER_COMPOSE_TIMEOUT;
loop {
let policy = get_active_policy(client, sandbox_name).await?.unwrap_or_default();
if crate::provider_capabilities::provider_is_composed(&policy, provider_name) {
return Ok(());
}
if Instant::now() >= deadline {
return Err(miette::miette!(
"provider {provider_name} attached but not composed into sandbox {sandbox_name} \
within {PROVIDER_COMPOSE_TIMEOUT:?}: providers_v2_enabled may be off on the gateway"
));
}
tokio::time::sleep(PROVIDER_COMPOSE_POLL).await;
}
}
You may adjust wording slightly for ASCII and style, but preserve semantics:
polls active policy with get_active_policy
defaults missing policy payload to default
succeeds only when provider_is_composed returns true
timeout error mentions provider, sandbox, timeout, and likely providers_v2_enabled cause
propagates get_active_policy errors
Verification:
Run devenv shell -- cargo check -p right-openshell.
Commit:
git add crates/right-openshell/src/openshell.rsgit commit -m "feat(providers): wait_for_provider_composed polls active policy for composed rule"
Step 2: Run devenv shell -- cargo test -p right-openshell provider_is_composed and confirm it fails because provider_is_composed does not exist.
Step 3: In provider_capabilities.rs, add directly after rule_for_provider:
rust
/// True when the provider's composed `_provider_<name>` rule is present in the
/// sandbox's active policy. This is the direct composition signal — use it to
/// confirm composition actually happened, never the `policy set` return value.
pub fn provider_is_composed(policy: &SandboxPolicy, provider_name: &str) -> bool {
rule_for_provider(policy, provider_name).is_some()
}
Use ASCII punctuation in edited source comments if the file is ASCII-only.
Step 4: Run devenv shell -- cargo test -p right-openshell provider_is_composed and confirm it passes.
Step 5: Commit exactly this task with:
git add crates/right-openshell/src/provider_capabilities.rs crates/right-openshell/src/provider_capabilities_tests.rsgit commit -m "feat(providers): provider_is_composed predicate over active policy"
Context
provider_capabilities.rs already has a private rule_for_provider(policy, provider_name) that computes the _provider_ rule key match using sanitize. This task exposes that existing logic as a small public predicate so later code can confirm active-policy composition after a reload.
When adding a cargo dependency, find the latest version from registry unless I ask for a specific one.
Git workflow
Use Conventional Commits for commit messages: type(scope): subject. Prefer common types such as feat, fix, docs, refactor, test, chore, ci, build, and perf. Use ! or a BREAKING CHANGE: footer for breaking changes.
Don't do git push unless creating or syncing a pull request.
When syncing branch with default branch, always rebase instead of merge.
When asked to merge a PR, after successful merge, checkout default branch and pull merge commit from origin.
IMPORTANT: When superpowers writes a brainstorm spec, do NOT create a new branch unless explicitly asked to.
Tools & environment
Do not trust LSP diagnostics for verifying code correctness — they are often stale, especially after subagent work. Run the actual compiler/checker instead.
Never use haiku models for subagents. Use sonnet at minimum, opus for complex tasks.
Dispatch subagents for complex tasks to keep main context lean.
When running shell commands (not via Grep/Glob tools), prefer rg over grep and fd over find.
If a binary is absent from $PATH, use nix run nixpkgs#<package-name> -- <command> instead of installing globally.
If devenv.nix exists in repo root, prefix all commands with devenv shell -- <command>.
Never kill devenv processes with -9. Use just kill or killall.
Don't run commands in home dir (~, /Users/...) unless explicitly asked. The only exception is fd.
Keep worktrees in current project's git root .worktrees/.
Safety
NEVER get secrets into your context.
When writing shell scripts (bash, zsh, sh, nushell) always verify syntax is correct.
--- project-doc ---
@AGENTS.rust.md
This is a Rust project. Follow conventions in AGENTS.rust.md.
Project
Right Agent
Right Agent is an opinionated, closed-box AI agent platform — peer to OpenClaw and Hermes in category. Every choice is made for you, security is the default, and we polish what ships before adding more. Built on Claude Code running inside NVIDIA OpenShell sandboxes, orchestrated by process-compose. Drop-in compatible with the OpenClaw/ClawHub ecosystem at the file level (same conventions, same skill format, same registry) — but with security-first enforcement instead of "grant all, pray it works."
Core Value: One Telegram bot per agent — every chat its own Claude Code session over a shared, chat-tagged memory. Every agent in its own sandbox, every credential outside it. The box is closed; you just use it.
Constraints
Language: Rust (edition 2024)
Dependencies: process-compose (external), OpenShell (external), Claude Code CLI (external)
Platforms: Linux and macOS
Compatibility: Drop-in compatible with OpenClaw file conventions and ClawHub SKILL.md format
Security: Agents default to OpenShell sandbox (sandbox: mode: openshell). Agents needing host access (computer-use, Chrome) can use sandbox: mode: none. Always --dangerously-skip-permissions — OpenShell policy is the security layer for sandboxed agents.
OpenShell status: Alpha software — may have breaking changes. Design for resilience.
Stack: Cargo.toml is the source of truth for dependencies. Project standards in AGENTS.rust.md.
Docs
Always commit docs/superpowers/ spec and plan files. Never leave them untracked.
Verification cadence
Tests are milestone checks, not punctuation after every edit. Batch small edits and avoid repeating cargo checks/tests when the signal would be the same.
At the start of substantial feature work or a new worktree, run one baseline verification appropriate to the scope. Prefer targeted package/module tests for narrow work; use full workspace tests only when the change is broad or the baseline is uncertain. Record any pre-existing failures.
During implementation, prefer the narrowest useful command (devenv shell -- cargo test -p <crate> <filter>, package-level tests, or a targeted build/check) after a TDD red/green loop or a coherent feature slice.
At the end of all code work, including work done inside a worktree, devenv shell -- cargo test --workspace is mandatory. Targeted tests do not replace the final full workspace test.
New docs/superpowers/ plans must encode this cadence: targeted intermediate verification and one final full workspace test, not full workspace tests after every task.
Conventions
Bot-first management: MCP management goes through the Telegram Mini App dashboard opened by /mcp; model/runtime controls such as /model remain bot-managed. Never create or edit .mcp.json, agent configs, or credential files manually — the bot/dashboard is the control plane.
Provider management: Provider management goes through the Telegram Mini App dashboard opened by /providers. Never create or edit gateway providers via host CLI or agent.yaml directly — the bot/dashboard is the control plane.
Debuggability over convenience: Always prefer direct, observable signals over indirect heuristics. If an API provides status, use it — don't infer status from side effects (e.g. SSH connectivity as a proxy for sandbox readiness). Errors must propagate to logs, never be silently swallowed.
Domain research before implementation: Always verify external tool APIs by reading source code or running --help before writing integration code. Never rely solely on web documentation — it may be outdated or wrong.
PROMPT_SYSTEM.md: Always keep PROMPT_SYSTEM.md in sync with the actual prompting system. When changing system prompt generation, agent definitions, JSON schemas, or MCP instructions, update PROMPT_SYSTEM.md to match.
Prompt-tier brevity: Files that ship to every CC invocation as part of the composite system prompt — crates/right-codegen/templates/right/prompt/OPERATING_INSTRUCTIONS.md, CRON_INSTRUCTIONS.md, templates/right/agent/BOOTSTRAP.md, and the base prompt assembled in crates/right-codegen/src/agent_def.rs::generate_system_prompt — are paid for in tokens on every turn. State rules in 1-3 sentences, prefer declarative facts over imperative narration, cut JSON/YAML examples when prose already covers the rule, and avoid duplicating anything already in another section of the same composite prompt. Long narration belongs in PROMPT_SYSTEM.md (operator-facing), not in the prompt itself. The base prompt (generate_system_prompt) and OPERATING_INSTRUCTIONS.md must not duplicate rules; their split follows the boundary invariant in PROMPT_SYSTEM.md (base = parameterized values + the Bootstrap-universal minimum; OPERATING = operating-only procedure).
MCP with_instructions(): When adding, removing, or renaming MCP tools, always update with_instructions() in both memory_server.rs and aggregator.rs to reflect the current tool set and descriptions.
MCP tool names in agent-facing text: CC prefixes MCP tools as mcp__{server}__{tool}. The Right Agent server is "right", so agents see mcp__right__<tool>. All skills, templates, prompts, and codegen that reference tool names for agents must use the full prefixed form. When adding, removing, or renaming tools, update references in: skills/, templates/right/, crates/right-agent/src/codegen/agent_def.rs, PROMPT_SYSTEM.md.
Debugging agent sessions: In development, bots run with --debug. Three log sources: (1) CC debug logs at ~/.claude/logs/ inside sandbox (/sandbox/.claude/logs/) or on host for --no-sandbox; (2) stream NDJSON logs at ~/.right/logs/streams/<session-uuid>.ndjson on host; (3) process-compose per-process logs via REST API: curl -s "http://localhost:18927/process/logs/{process-name}/0/50" (e.g. right-mcp-server, right-bot). Bot and aggregator are separate processes — always check both when debugging MCP issues.
Reproduce a sandbox claude invocation by hand: To debug a sandboxed claude -p invocation manually (e.g. the learning prefilter or any agent turn), SSH into the agent's OpenShell sandbox and run claude with the agent's own token. The SSH config is at ~/.right/run/ssh/<sandbox-name>.ssh-config and the host alias is openshell-<sandbox-name> (the openshell- prefix is what right_openshell::openshell::ssh_host_for_sandbox produces; sandbox names come from openshell sandbox list). The agent's Claude OAuth token lives in its per-agent DB and must be injected as CLAUDE_CODE_OAUTH_TOKEN — exactly what the bot does in build_claude_command (crates/bot/src/cc/invocation.rs):
sh
SSHCFG=~/.right/run/ssh/right-him-20260516-1649.ssh-config
TOKEN=$(sqlite3 -readonly ~/.right/agents/him/data.db "SELECT token FROM auth_tokens LIMIT 1;")
ssh -F "$SSHCFG" openshell-right-him-20260516-1649 \
"export CLAUDE_CODE_OAUTH_TOKEN='$TOKEN'; cd /sandbox && claude -p --output-format json -- 'hi'"
Keep the token in a shell variable only — never echo or print it (project rule: never get secrets into context). Sandbox claude may return Not logged in · Please run /login after the on-disk token expires (OpenShell #1603); injecting CLAUDE_CODE_OAUTH_TOKEN bypasses that for ad-hoc tests.
Worktree binary for right: When operating inside this repo, never invoke bare right — $PATH may resolve to a stale installed copy. Use cargo run [--release] --bin right -- <args> or the explicit target/devenv/<release|debug>/right. right up bakes current_exe() into process-compose.yaml and refuses to regenerate while PC is healthy, so one wrong invocation pins the wrong binary until right down.
Self-healing platform: Never manually fix agent sandboxes, configs, or state. If a platform change breaks an agent, the platform code must detect and recover automatically (re-upload if files are missing, adjust policy, etc.). Manual fixes mask bugs and prevent proper testing.
Never delete sandboxes for recovery: Sandboxes contain agent data (credentials, installed tools, agent-created files). Deleting a sandbox destroys this data. Platform changes must be designed to work with existing sandboxes — never require sandbox recreation as a migration path.
Upgrade-friendly design: Every new feature must be adoptable by already-deployed agents without recreation. New config fields default to the previous behavior (backward-compatible defaults). agent config must expose all user-facing settings — if a feature exists but can't be toggled via CLI, it's incomplete. Think in terms of upgrades, not fresh installs.
Bot-managed fields are a documented exception to the CLI-exposure rule. Operational/runtime concerns reached over Telegram or the Telegram Mini App dashboard (/mcp, /model) are intentionally not mirrored as right agent config flags — the bot/dashboard is the control plane for these, and agent.yaml (the source of truth) remains directly user-editable for out-of-band changes.
Simplest for the user, most maintainable for us. When a feature has
multiple working implementations, choose the one that (a) gives the user
fewer steps and an explicit, auditable choice, and (b) reuses existing,
tested paths instead of new control planes or invariant hybrids. Add new
gateway/sandbox surface only when it is isolated and additive, not when the
alternative smears complexity across load-bearing machinery.
Architecture docs split
ARCHITECTURE.md is prescriptive only — load-bearing rules,
contracts, gotchas, reference tables, schema/protocol invariants. It is
@-imported and loads on every conversation; every line costs tokens.
Hard budget: ARCHITECTURE.md MUST stay under 40k characters. If an
edit would push it over, cut something else or move content to a
satellite in the same commit. This is non-negotiable — at 40k+ the
CLI warns and downstream conversations pay the cost on every turn.
Descriptive content (data flows, feature walkthroughs, mechanism
narration, "first X happens, then Y, then Z" sequences, helper-method
inventories) lives in docs/architecture/*.md. Reference satellites by
plain path in ARCHITECTURE.md or here — never @-import them.
That is the whole point of the split.
Default for new content is the satellite. Before adding to
ARCHITECTURE.md, the change must clear all three tests:
Rule test: does it say what code MUST or MUST NOT do? ("X is
forbidden", "every Y goes through Z", "MUST use helper W") If it
narrates what happens, it's descriptive — satellite.
Enforcement test: is there a compiler check, test, or
review-blocking pattern that catches violations? If it's just "good
to know", it's descriptive — satellite.
Brevity test: can the rule be stated in ≤3 sentences (or one
table row)? If you need a walkthrough to convey it, the walkthrough
belongs in the satellite and only the rule statement stays here.
Sentinel phrases that mean "move it out": "The X subsystem works
by…", "First X, then Y, then Z", "X is implemented as…", "The flow is…",
"This was historically…", numbered step-by-step procedures longer than
3 steps, helper-method bullet lists.
Cite-on-touch (mandatory): when modifying a subsystem, re-read the
corresponding docs/architecture/<x>.md and update it if drifted. These
docs are not auto-loaded, so they will rot silently if not maintained.
Code is authoritative; the satellite doc is a courtesy to readers.
When in doubt, put it in the satellite and link from ARCHITECTURE.md
with a one-line summary. It is always easier to promote a rule later
than to evict descriptive text once it's wedged into the prescriptive
doc.
Architecture
@ARCHITECTURE.md
Update ARCHITECTURE.md only when contracts, invariants, or
review-blocking rules change (new mandatory crate boundary, new
codegen category, new MCP routing rule, new sandbox-policy invariant).
Routine evolution — added features, new data flows, refactored helpers,
new walkthroughs — goes into docs/architecture/*.md instead.