diff --git a/config/ast-grep/rule-tests/orchestration-agent-kind-branch-test.yml b/config/ast-grep/rule-tests/orchestration-agent-kind-branch-test.yml index cfa0617bd35..b03eddcaf39 100644 --- a/config/ast-grep/rule-tests/orchestration-agent-kind-branch-test.yml +++ b/config/ast-grep/rule-tests/orchestration-agent-kind-branch-test.yml @@ -3,9 +3,17 @@ valid: - const party = resolveOrchestrationParty(address, db) - if (party.terminalHandle === undefined) { return } - const local = target.startsWith('run:') + - const id = party.orcaSessionId ?? fallback + - 'send({ handle: party.terminalHandle })' invalid: - if (to.startsWith(ORCA_SESSION_ADDRESS_PREFIX)) { return } - const session = parseOrcaSessionAddress(to) - if (party.orcaSessionId !== null) { notify() } - if (agent.kind === 'structured') { inject() } - const chat = !isTuiAgent(agent) + - if (agent.kind !== 'structured') { inject() } + - if (party.orcaSessionId) { inject() } + - if (party.orcaSessionId != null) { inject() } + - const terminal = !party.orcaSessionId + - const handle = party.terminalHandle && pointer(party.terminalHandle) + - "const route = caller.orcaSessionId ? 'chat' : 'terminal'" diff --git a/config/ast-grep/rules/orchestration-agent-kind-branch.yml b/config/ast-grep/rules/orchestration-agent-kind-branch.yml index a8a5500f2c4..98cd0a756ad 100644 --- a/config/ast-grep/rules/orchestration-agent-kind-branch.yml +++ b/config/ast-grep/rules/orchestration-agent-kind-branch.yml @@ -28,11 +28,26 @@ rule: # Party shape - pattern: $P.orcaSessionId !== null - pattern: $P.orcaSessionId === null + - pattern: $P.orcaSessionId != null + - pattern: $P.orcaSessionId == null - pattern: $P.terminalHandle === null - pattern: $P.terminalHandle !== null + - pattern: $P.terminalHandle != null + - pattern: $P.terminalHandle == null + # Party shape tested for truthiness: `if (p.orcaSessionId)`, `!p.x`, `p.x && …`, `p.x ? …` + - all: + - kind: member_expression + - has: { field: property, regex: '^(orcaSessionId|terminalHandle)$' } + - any: + - inside: { kind: parenthesized_expression, inside: { kind: if_statement } } + - inside: { kind: unary_expression, has: { field: operator, regex: '^!$' } } + - inside: { kind: binary_expression, has: { field: operator, regex: '^(&&|\|\|)$' } } + - inside: { kind: ternary_expression, field: condition } # Kind and mode literals - pattern: $K.kind === 'structured' + - pattern: $K.kind !== 'structured' - pattern: $K.mode === 'structured' + - pattern: $K.mode !== 'structured' - pattern: isTuiAgent($$$) # Caller kind read from the environment - pattern: readInjectedAgentSessionId($$$) diff --git a/config/orchestration-agent-kind-baseline.txt b/config/orchestration-agent-kind-baseline.txt index b4b00f20efc..cd17b804f3f 100644 --- a/config/orchestration-agent-kind-baseline.txt +++ b/config/orchestration-agent-kind-baseline.txt @@ -4,14 +4,22 @@ 2 src/cli/handlers/orchestration/message-send-handler.ts 4 src/cli/handlers/orchestration/terminal-identity.ts 1 src/main/runtime/orchestration/crew/crew-parent-inputs.ts +1 src/main/runtime/orchestration/crew/crew-parent-relations.ts 4 src/main/runtime/orchestration/crew/crew-parties.ts -2 src/main/runtime/orchestration/crew/crew-party-snapshot.ts +7 src/main/runtime/orchestration/crew/crew-party-snapshot.ts +1 src/main/runtime/orchestration/crew/crew-query.ts +11 src/main/runtime/orchestration/crew/crew-recipient-availability.ts +6 src/main/runtime/orchestration/crew/crew-recipient-inputs.ts 1 src/main/runtime/orchestration/crew/crew-recipient-owner-queries.ts +1 src/main/runtime/orchestration/crew/crew-recipient-worker-facts.ts 3 src/main/runtime/orchestration/db/dispatch-context/worker-follow-up-lineage.ts +3 src/main/runtime/orchestration/db/legacy/legacy-compatibility-candidates.ts 1 src/main/runtime/orchestration/db/runs/run-lookup.ts 1 src/main/runtime/orchestration/db/schema/structured-worker-orca-session-backfill.ts 1 src/main/runtime/orchestration/mailbox/routing/structured-session-mail-address.ts 3 src/main/runtime/orchestration/mailbox/routing/structured-session-mail-target.ts +2 src/main/runtime/orchestration/mailbox/senders/accepted-answer-sender.ts +4 src/main/runtime/orchestration/mailbox/senders/agent-message-relation.ts 1 src/main/runtime/orchestration/mailbox/senders/agent-message-sender.ts 2 src/main/runtime/orchestration/terminal-authority/structured-sessions/structured-worker-authority.ts 1 src/main/runtime/orchestration/terminal-authority/structured-sessions/structured-worker-custody.ts @@ -25,13 +33,18 @@ 1 src/main/runtime/orchestration/workers/turn-stops/chat-worker-error-escalation.ts 1 src/main/runtime/rpc/methods/orchestration/caller-show.ts 1 src/main/runtime/rpc/methods/orchestration/federation/federated-worker-start.ts +1 src/main/runtime/rpc/methods/orchestration/messaging/finished-worker-mail.ts 3 src/main/runtime/rpc/methods/orchestration/messaging/recipient-routing.ts 1 src/main/runtime/rpc/methods/orchestration/messaging/send-methods.ts 6 src/main/runtime/rpc/methods/orchestration/messaging/session-recipient.ts 1 src/main/runtime/rpc/methods/orchestration/messaging/settled-worker-follow-through.ts -1 src/main/runtime/rpc/methods/orchestration/runs/dispatch-creator.ts +3 src/main/runtime/rpc/methods/orchestration/runs/dispatch-creator.ts 1 src/main/runtime/rpc/methods/orchestration/worker/deliver-worker-dispatch-preamble.ts +1 src/main/runtime/rpc/methods/orchestration/worker/local-worker-start-dispatch.ts 1 src/main/runtime/rpc/methods/orchestration/worker/worker-configured-agent-preflight.ts +1 src/main/runtime/rpc/methods/orchestration/worker/worker-control.ts 1 src/main/runtime/rpc/methods/orchestration/worker/worker-earlier-work.ts 1 src/main/runtime/rpc/methods/orchestration/worker/worker-follow-up-placement.ts 1 src/main/runtime/rpc/methods/orchestration/worker/worker-start-validation.ts +1 src/main/runtime/rpc/orchestration-legacy-compatibility.ts +2 src/main/runtime/rpc/orchestration-legacy-coordinator-authority.ts diff --git a/config/scripts/static-analysis/orchestration-parity/check-orchestration-parity-declarations.mjs b/config/scripts/static-analysis/orchestration-parity/check-orchestration-parity-declarations.mjs index 619c0e73706..a090311f4e9 100644 --- a/config/scripts/static-analysis/orchestration-parity/check-orchestration-parity-declarations.mjs +++ b/config/scripts/static-analysis/orchestration-parity/check-orchestration-parity-declarations.mjs @@ -21,16 +21,14 @@ const CELL = /^(?:supported(?:: .+)?|refused `([a-z_]+)`: .+|n\/a: .+)$/ // Both catalog lists are generated from the registry: methods with shared params, then those without. export function registeredMethods(catalogText) { - return new Set( - [...catalogText.matchAll(/^\s*'(orchestration\.[A-Za-z]+)'[:,\n]/gm)].map((m) => m[1]) - ) + return new Set([...catalogText.matchAll(/^\s*'(orchestration\.[^']+)'[:,\n]/gm)].map((m) => m[1])) } /** Each `## \`orchestration.x\`` section, as its `-