-
Notifications
You must be signed in to change notification settings - Fork 1
chore: sync public mirror from internal #821
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
docs/superpowers/plans/2026-07-13-automatic-oracle-policy.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| # Automatic Oracle Consultation Policy Implementation Plan | ||
|
|
||
| > **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. | ||
|
|
||
| **Goal:** Automatically and audibly recommend or require the read-only Oracle for tasks where independent reasoning is likely to improve outcomes. | ||
|
|
||
| **Architecture:** A pure versioned policy evaluates profile, task type, prompt signals, and prior failures. The intelligent router records the decision, and the chat handler injects explicit next-run guidance; a checked-in eval matrix prevents trigger drift. | ||
|
|
||
| **Tech Stack:** TypeScript, Vitest, intelligent router, Agent system-prompt additions. | ||
|
|
||
| ## Global Constraints | ||
|
|
||
| - No hidden tool execution; the agent sees and follows an explicit policy directive. | ||
| - Oracle remains read-only and uses the profile’s complementary model. | ||
| - Low-risk profiles avoid mandatory Oracle cost. | ||
| - Policy behavior must be covered by named eval cases before integration. | ||
|
|
||
| --- | ||
|
|
||
| ### Task 1: Versioned consultation policy | ||
|
|
||
| **Files:** Create `src/agent/oracle-consultation-policy.ts`; test `test/agent/oracle-consultation-policy.test.ts`. | ||
|
|
||
| - [x] Write a failing eval matrix for low, medium, high, ultra, architecture/migration, ambiguity, cross-cutting work, and repeated failures. | ||
| - [x] Implement minimal deterministic scoring and prompt directive formatting. | ||
| - [x] Verify all eval cases pass. | ||
|
|
||
| ### Task 2: Router and runtime integration | ||
|
|
||
| **Files:** Modify intelligent-router types/normalization/service/recorder and `src/server/handlers/chat.ts`; update focused tests. | ||
|
|
||
| - [x] Add failing tests for decision recording and next-run prompt injection. | ||
| - [x] Thread task summary and prior failure count through routing. | ||
| - [x] Queue policy guidance only for recommended/required modes. | ||
| - [ ] Run targeted tests, lint, affected tests, commit, open PR after PR 2 merges, address feedback, merge, and verify deployment/mirror workflows. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| import type { AgentProfileLevel } from "./profiles.js"; | ||
|
|
||
| export const ORACLE_CONSULTATION_POLICY_VERSION = | ||
| "evalops.maestro.oracle-consultation.v1"; | ||
|
|
||
| export type OracleConsultationMode = "available" | "recommended" | "required"; | ||
|
|
||
| export interface OracleConsultationPolicyInput { | ||
| profileLevel: AgentProfileLevel; | ||
| taskType: string; | ||
| taskSummary?: string; | ||
| priorFailures?: number; | ||
| } | ||
|
|
||
| export interface OracleConsultationDecision { | ||
| policyVersion: typeof ORACLE_CONSULTATION_POLICY_VERSION; | ||
| evalSuite: "oracle-consultation-policy-v1"; | ||
| mode: OracleConsultationMode; | ||
| reasons: string[]; | ||
| } | ||
|
|
||
| const CONSULTATION_TASK_TYPES = new Set([ | ||
| "architecture", | ||
| "code_review", | ||
| "discovery", | ||
| "incident_response", | ||
| "migration", | ||
| "planning", | ||
| "security_review", | ||
| ]); | ||
|
|
||
| const UNCERTAINTY_PATTERN = | ||
| /\b(?:ambiguous|unclear|uncertain|trade-?offs?|cross[- ]cutting|multiple approaches|data loss|irreversible|root cause unknown)\b/i; | ||
|
|
||
| const CONSULTATION_PROMPT_PATTERN = | ||
| /\b(?:architect(?:ure|ural|ing)?|migrat(?:e|es|ed|ing|ion)|security|secure|threat model(?:ing)?|auth(?:entication|orization)?|schema (?:change|migration)|backfill)\b/i; | ||
|
|
||
| export function recommendOracleConsultation( | ||
| input: OracleConsultationPolicyInput, | ||
| ): OracleConsultationDecision { | ||
| const reasons: string[] = []; | ||
| const priorFailures = Math.max(0, Math.floor(input.priorFailures ?? 0)); | ||
| let mode: OracleConsultationMode = "available"; | ||
|
|
||
| if (input.profileLevel === "ultra") { | ||
| mode = "required"; | ||
| reasons.push("ultra_profile"); | ||
| } else if (input.profileLevel === "high") { | ||
| mode = "recommended"; | ||
| reasons.push("high_profile"); | ||
| } | ||
|
|
||
| if (CONSULTATION_TASK_TYPES.has(input.taskType.trim().toLowerCase())) { | ||
| if (mode === "available") mode = "recommended"; | ||
| reasons.push("consultation_task_type"); | ||
| } | ||
|
|
||
| if (input.taskSummary && UNCERTAINTY_PATTERN.test(input.taskSummary)) { | ||
| if (mode === "available") mode = "recommended"; | ||
| reasons.push("uncertainty_signal"); | ||
| } | ||
|
|
||
| if ( | ||
| input.taskSummary && | ||
| CONSULTATION_PROMPT_PATTERN.test(input.taskSummary) | ||
| ) { | ||
| if (mode === "available") mode = "recommended"; | ||
| reasons.push("consultation_prompt_signal"); | ||
| } | ||
|
|
||
| if (priorFailures >= 2) { | ||
| mode = input.profileLevel === "low" ? "recommended" : "required"; | ||
| reasons.push("repeated_failures"); | ||
| } | ||
|
|
||
| if (reasons.length === 0) reasons.push("oracle_available_on_demand"); | ||
| return { | ||
| policyVersion: ORACLE_CONSULTATION_POLICY_VERSION, | ||
| evalSuite: "oracle-consultation-policy-v1", | ||
| mode, | ||
| reasons, | ||
| }; | ||
| } | ||
|
|
||
| export function formatOracleConsultationDirective( | ||
| decision: OracleConsultationDecision, | ||
| ): string { | ||
| const instruction = | ||
| decision.mode === "required" | ||
| ? "You MUST consult the read-only Oracle once before committing to the plan or final answer. Incorporate or explicitly rebut its advice." | ||
| : decision.mode === "recommended" | ||
| ? "Consult the read-only Oracle once before committing to the plan or final answer unless the task has become clearly bounded; if you skip it, state the concrete reason." | ||
| : "The read-only Oracle is available on demand."; | ||
| return [ | ||
| `Oracle consultation policy (${decision.policyVersion})`, | ||
| instruction, | ||
| `Triggers: ${decision.reasons.join(", ")}.`, | ||
| ].join("\n"); | ||
| } | ||
|
|
||
| export function applyOracleConsultationDirective( | ||
| agent: { queueNextRunSystemPromptAddition(text: string): void }, | ||
| decision: OracleConsultationDecision | undefined, | ||
| ): boolean { | ||
| if (!decision || decision.mode === "available") return false; | ||
| agent.queueNextRunSystemPromptAddition( | ||
| formatOracleConsultationDirective(decision), | ||
| ); | ||
| return true; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.