/** * Goal queue (v1.1) — 1-active-per-org semaphore + FIFO queue. * * Per v1.1 PRD §12.1. SoloSquad supports parallel goals across orgs but * within a single org only one goal runs at a time. Two reasons: * * 1. A goal cycle holds the chief session and frequently dispatches to * PM + specialists — concurrent goals would multiply Claude Code * sessions and budget burn beyond the founder's intent. * 2. Goals share org-level memory (archive.sqlite, customers.md). Two * simultaneous keep/discard cycles on the same domain context would * produce racing decisions. * * Layout: * /goals/.active-goal ← single-line file with active goal id * /goals/.goal-queue ← jsonl, one queued goal id per line * * Both files are conventional plain text — git-able, observable, and * trivial to inspect with `cat`. Concurrent writers should serialize * through chief-runner's session mutex. */ export interface GoalQueueOpts { /** Org root, e.g. `//`. */ orgRoot: string; } interface QueueEntry { goal_id: string; /** ISO 8601 enqueue time. */ enqueued_at: string; } /** Currently active goal id, or null if none is running. */ export declare function getActive(opts: GoalQueueOpts): string | null; /** * Acquire the active slot for `goalId`. Throws if another goal is already * active. Caller (goal-runner) holds the slot until `release` is called. */ export declare function acquire(opts: GoalQueueOpts, goalId: string): void; /** * Release the active slot. Idempotent — releasing a non-active goal is a * no-op (so callers can safely cleanup in finally blocks). */ export declare function release(opts: GoalQueueOpts, goalId: string): void; /** Append a goal id to the queue. Duplicate enqueues are silently dropped. */ export declare function enqueue(opts: GoalQueueOpts, goalId: string): void; /** Return the queue in FIFO order without modifying state. */ export declare function listQueue(opts: GoalQueueOpts): QueueEntry[]; /** * Take the head of the queue (FIFO). Returns the goal id, or null if the * queue is empty. The queue file is updated atomically (single * writeFileSync) so concurrent calls are safe when serialized through * the chief-runner mutex. */ export declare function dequeue(opts: GoalQueueOpts): string | null; /** Remove `goalId` from the queue if present. Used by `goal stop`. */ export declare function remove(opts: GoalQueueOpts, goalId: string): boolean; /** * Promote next queued goal to active if no goal is currently active. * Returns the newly active goal id, or null if either (a) something is * already running or (b) the queue is empty. Idempotent. */ export declare function promoteNext(opts: GoalQueueOpts): string | null; export {};