import { PromptModule, ModuleConfig } from './prompt-module.interface.js'; /** * Request Contract block (P0-3). * * Per spec * `.crewly/specs/2026-05-03-agent-improvement-p0-execution.md` §"Fix P0-3", * this module emits a role-shaped Request Contract section. The contract * defines the seven canonical fields a Request carries — Goal, Expected * Outcome, Eval Criteria, Constraints, Decision Rights, Escalation * Conditions, Done Definition — and pins **Goal + Expected Outcome + Eval * Criteria** as the mandatory floor that every delegated subtask MUST carry. * * The module emits one of three role-shaped sections: * * 1. **Orchestrator** (orgRole === 'orchestrator' OR role === 'orchestrator'): * Full Request Contract field table + the rule that every delegated * subtask MUST carry G+O+E + the rejection rule TLs apply downstream. * * 2. **Team Lead** (orgRole === 'team-lead' OR canDelegate === true): * Brief Reception Protocol — receive task, verify G+O+E present, push * back to delegator if any are missing, propagate G+O+E verbatim when * sub-delegating to workers. * * 3. **Worker / executor** (everyone else): * Short G+O+E assertion — every task you accept should carry Goal, * Expected Outcome, and Eval Criteria; if any is missing, ask the * delegator (your TL or the orchestrator) before starting. * * Why a module (not just per-role markdown)? * - Authority text must be identical across every agent of the same role. * A module guarantees byte-identical output instead of relying on N role * prompts staying in sync over time. * - The text is small and authority-defining, so it cannot be truncated * under budget pressure → `compactable = false` (Trusted Zone). * - Sits at priority 3.6 — immediately after DecisionRights (priority 3.5), * immediately before MemoryReference (priority 4). The contract belongs * in the authority cluster (Identity → Soul/Recovery → RoleBoundary → * DecisionRights → **RequestContract** → MemoryReference) so an agent * reads "what is a well-formed task" right after "who am I, what can I * decide". * * Static role prompts under `config/roles/orchestrator/prompt.md` and * `config/roles/team-leader/{prompt.md,tl-addon.md}` ALSO contain the * orchestrator + TL sections verbatim — this is intentional belt-and- * suspenders coverage for the legacy `prompt-builder.service.ts` load path * which does not run through `PromptAssemblyService`. The two paths * produce different prompts for different runtimes; both must carry the * contract. * * Net-zero offset: legacy "ask clarifying questions" / "if anything's * unclear, ask" soft hints have been deleted from worker role prompts * because this module + the structured G+O+E assertion supersede them. */ export declare class RequestContractModule implements PromptModule { name: string; priority: number; maxTokens: number; compactable: boolean; /** * Always include — every agent participates in the Request lifecycle: * orchestrators issue contracts, TLs verify-and-propagate, workers * consume. The block is small and the role-shape switch is internal. * * @param _config - Unused; the inclusion rule is universal * @returns Always true */ shouldInclude(_config: ModuleConfig): boolean; /** * Build the role-shaped Request Contract section. * * Resolves the agent's role-shape via three stacked checks (in order): * 1. `orgRole === 'orchestrator'` OR `role === 'orchestrator'` → orchestrator block * 2. `orgRole === 'team-lead'` OR `canDelegate === true` → TL Brief Reception Protocol * 3. anything else → Worker G+O+E assertion * * The role-shape inputs match the resolution order used by other * authority modules (e.g. RoleBoundaryModule). Tests pin the matrix. * * @param config - Module configuration * @returns Formatted markdown block with the role-shaped section */ build(config: ModuleConfig): Promise; /** * Build the orchestrator-side Request Contract. * * @returns Markdown block: `## Request Contract` with the seven-field * table, G+O+E mandatory rule, and downstream rejection clause. */ private buildOrchestratorBlock; /** * Build the team-lead-side Brief Reception Protocol. * * @returns Markdown block: `## Brief Reception Protocol` with the * three-step verify / push-back / propagate-verbatim contract. */ private buildTeamLeadBlock; /** * Build the worker-side G+O+E assertion. * * @returns Markdown block: `## Request Contract — What You Should See` * reminding workers to expect G+O+E in every task and to ask if any * is missing. */ private buildWorkerBlock; } //# sourceMappingURL=request-contract.module.d.ts.map