Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
refactor: drop the spec helpers nothing outside the tests calls (#5992)
[._.]/ Adam Eivydf466ad59149
diff --git a/server/lib/README.md b/server/lib/README.mdindex a16f8b624a..f5fd005817 100644--- a/server/lib/README.md+++ b/server/lib/README.md@@ -477,7 +477,7 @@ pm` default, `NPM_CONFIG_PREFIX`, nvm/Volta) installed `codex` successfully and| `objects.js` | Object utilities — `deepMerge` (recursive merge w/ array replacement), `isPlainObject` (non-null, non-array `object` guard for JSON / LLM payloads), `POLLUTING_KEYS` (shared `__proto__`/`constructor`/`prototype` denylist for sanitizers), `canonicalStringify` (recursive sorted-key JSON serialization for cross-machine content hashing), `isEmptyScalar` (true for null/undefined/whitespace-string/empty-array — merge gap-fill gate). || `openapiSpec.js` | Builds two OpenAPI 3.0.3 documents: the Settings-controlled exposed public surface and the complete internal HTTP inventory. Detailed operations reuse canonical Zod contracts; generated operations are visibly labeled rather than claiming unmodeled schemas. || `openapiDowngrade.js` | `OPENAPI_VERSION` plus `toOpenApi30Schema` / `toOpenApi30Operation`, which rewrite Zod's draft-2020-12 output (null unions, numeric exclusive bounds, `const`, tuples, `propertyNames`) into the OpenAPI 3.0.3 dialect. Apply ONLY at the OpenAPI document boundary — the AsyncAPI payloads, CoS provider tool definitions, and tool resource read the same schemas as plain JSON Schema, where these rewrites silently widen bounds and drop null branches. |-| `orchestrationProfile.js` | Orchestrated CoS execution (#5992) — `ORCHESTRATION_MODES` / `ORCHESTRATION_ROLES` (architect, implementer, reviewer), `normalizeOrchestrationProfile` / `normalizeOrchestrationMode`, `isOrchestratedTask` / `roleAssignment` (both inert on a `direct` task, so a stored profile stays opt-in), the six-part `SPEC_PARTS` contract a delegated context-free lane needs, plus `formatReasoningDirective` / `parseReasoningDirective` (an unsupported rung is an error, never a silent downgrade) and `missingSpecParts`. |+| `orchestrationProfile.js` | Orchestrated CoS execution (#5992) — `ORCHESTRATION_MODES` / `ORCHESTRATION_ROLES` (architect, implementer, reviewer), `normalizeOrchestrationProfile` / `normalizeOrchestrationMode`, `isOrchestratedTask` / `roleAssignment` (both inert on a `direct` task, so a stored profile stays opt-in), the six-part `SPEC_PARTS` contract a delegated context-free lane needs, plus `parseReasoningDirective` (an unsupported rung is an error, never a silent downgrade). || `apiToolResource.js` | Builds the minimized semantic tool resource served at `/api/api-docs/tools.min.json` — only `x-portos-tool`-annotated operations, flattened to provider-neutral tool records with an HTTP binding and a shared error vocabulary. || `asyncApiSpec.js` | Builds the AsyncAPI 3 Socket.IO document from the generated event catalog with direction-aware operations and explicit modeled/generated payload status. || `mergeGateContract.js` | `mergeGateOwed({taskOpenPR, ownsPrWorkflow, leaveOpen})` decides whether a completing run actually owed its own PR merge; `resolveMergeGateVerdict({prProbe, summary, alreadyReprompted})` classifies a run that did (`merged` / `unreadable` / `leave-open-stated` / `needs-reprompt` / `reprompt-exhausted`) from the PR's live state and the agent's own sentinel text; `summaryStatesLeaveOpen` and `buildMergeGateReprompt` are its text-matching and corrective-prompt helpers. Pure — the PR lookup lives in `../services/prProbe.js`, the re-prompt delivery in `agentTuiSpawning.js`. |diff --git a/server/lib/orchestrationProfile.js b/server/lib/orchestrationProfile.jsindex 3453f8cfa5..ea43b8dec3 100644--- a/server/lib/orchestrationProfile.js+++ b/server/lib/orchestrationProfile.js@@ -46,7 +46,7 @@ const MAX_MODEL_ID_LENGTH = 300;* The six parts every delegated unit of work must carry. A delegated lane shares* NONE of the architect's context — it sees only the spec — so a spec missing* any of these is a lane that has to guess. Rendered into the doctrine section- * and used by `missingSpecParts` to check a spec the architect wrote.+ * so the architect prompt and any later spec check read one definition.*/export const SPEC_PARTS = Object.freeze([Object.freeze({ key: 'objective', label: 'OBJECTIVE', description: 'the single outcome this unit delivers, stated so it can be judged done or not' }),@@ -57,10 +57,6 @@ export const SPEC_PARTS = Object.freeze([Object.freeze({ key: 'reasoning', label: 'REASONING', description: `the effort rung for this step — one of ${EFFORT_LEVELS.join(', ')}` }),]);-export const SPEC_PART_KEYS = Object.freeze(SPEC_PARTS.map(part => part.key));--const SPEC_PART_BY_LABEL = new Map(SPEC_PARTS.map(part => [part.label, part]));-/** Directive line the architect writes to pin one step's reasoning effort. */export const REASONING_DIRECTIVE_LABEL = 'REASONING';@@ -133,11 +129,6 @@ export function roleAssignment(task, role) {return normalizeOrchestrationProfile(task?.metadata?.orchestrationProfile)?.[role] ?? null;}-/** Render the `REASONING: <rung>` line for a spec. */-export function formatReasoningDirective(rung) {- return `${REASONING_DIRECTIVE_LABEL}: ${rung}`;-}-/*** Parse a `REASONING: <rung>` directive out of spec text.*@@ -161,17 +152,3 @@ export function parseReasoningDirective(text) {return { rung };}-/**- * Which of the six spec parts a piece of spec text is missing, in canonical- * order. `[]` means the spec is complete.- */-export function missingSpecParts(text) {- if (typeof text !== 'string') return [...SPEC_PART_KEYS];- const present = new Set();- for (const line of text.split('\n')) {- const label = line.match(/^\s*(?:[-*]\s*)?(?:\*\*)?([A-Z]+)(?:\*\*)?\s*:/)?.[1];- const part = label ? SPEC_PART_BY_LABEL.get(label) : null;- if (part) present.add(part.key);- }- return SPEC_PART_KEYS.filter(key => !present.has(key));-}diff --git a/server/lib/orchestrationProfile.test.js b/server/lib/orchestrationProfile.test.jsindex b7f851a8d2..feb610a8e5 100644--- a/server/lib/orchestrationProfile.test.js+++ b/server/lib/orchestrationProfile.test.js@@ -2,10 +2,7 @@ import { describe, it, expect } from 'vitest';import {DEFAULT_ORCHESTRATION_MODE,ORCHESTRATION_ROLES,- SPEC_PART_KEYS,- formatReasoningDirective,isOrchestratedTask,- missingSpecParts,normalizeOrchestrationMode,normalizeOrchestrationProfile,parseReasoningDirective,@@ -64,8 +61,8 @@ describe('mode + role gating', () => {});describe('reasoning directives', () => {- it('round-trips a rung the architect wrote into a spec', () => {- const spec = `OBJECTIVE: ship it\n${formatReasoningDirective('xhigh')}`;+ it('reads the rung the architect wrote into a spec', () => {+ const spec = 'OBJECTIVE: ship it\nREASONING: xhigh';expect(parseReasoningDirective(spec)).toEqual({ rung: 'xhigh' });});@@ -81,25 +78,6 @@ describe('reasoning directives', () => {});});-describe('missingSpecParts', () => {- it('accepts plain and bulleted/bolded labels', () => {- const spec = [- 'OBJECTIVE: a',- '- FILES: b',- '- **INTERFACES**: c',- 'CONSTRAINTS: d',- 'VERIFICATION: npm test',- 'REASONING: low',- ].join('\n');- expect(missingSpecParts(spec)).toEqual([]);- });-- it('names every missing part in canonical order', () => {- expect(missingSpecParts('OBJECTIVE: a')).toEqual(SPEC_PART_KEYS.filter(k => k !== 'objective'));- expect(missingSpecParts(null)).toEqual([...SPEC_PART_KEYS]);- });-});-describe('role vocabulary', () => {it('is the plan → build → check triple the doctrine renders', () => {expect([...ORCHESTRATION_ROLES]).toEqual(['architect', 'implementer', 'reviewer']);