Skip to content

refactor(ai-autopilot): validate options, isolate onEvent, sharpen docs#30

Merged
suleimansh merged 1 commit into
mainfrom
quality/ai-autopilot
Jun 26, 2026
Merged

refactor(ai-autopilot): validate options, isolate onEvent, sharpen docs#30
suleimansh merged 1 commit into
mainfrom
quality/ai-autopilot

Conversation

@suleimansh

Copy link
Copy Markdown
Member

Code quality + docs pass for @gemstack/ai-autopilot (part of the per-package GemStack quality sweep).

Code quality

  • Fail-fast validation - Supervisor validates options at construction (plan must be a function, workers is required, concurrency/maxSubtasks must be positive integers) and run() rejects an empty task. Previously bad config surfaced deep inside a planner call with a confusing error.
  • Observer isolation - an onEvent callback that throws is now logged and swallowed (via a makeEmitter wrapper) so an observer bug can never abort a supervised run.
  • runPool clarity - marked @internal (used only by Supervisor, not re-exported) with full @param/@returns JSDoc.

Docs

  • Corrected usage semantics - SupervisorRun.usage aggregates dispatched-subtask usage only. The Planner/Synthesizer contracts return data, not usage, so planning/synthesis spend isn't observable. The doc previously over-claimed "across planning, dispatch, and synthesis".
  • Clarified maxSubtasks/budget are optional; added a defaultSynthesize example; updated the README guardrails section (incl. observer safety + construction-time validation).

Verification

Added tests for option validation, empty-task rejection, and onEvent isolation. Build + 21 tests green. Patch changeset included.

…docs

Code quality + docs pass for @gemstack/ai-autopilot:

- Supervisor validates options at construction (plan is a function,
  workers required, concurrency/maxSubtasks positive integers) and run()
  rejects an empty task, so misconfiguration fails fast with a clear
  message instead of deep inside a planner call.
- An onEvent callback that throws is now isolated (logged and swallowed)
  via a makeEmitter wrapper, so an observer bug cannot abort the run.
- Corrected SupervisorRun.usage docs: it aggregates dispatched-subtask
  usage only; the Planner/Synthesizer contracts return data not usage, so
  planning/synthesis spend is not observable by the supervisor.
- Clarified maxSubtasks/budget are optional, marked the internal runPool
  helper @internal with full JSDoc, added a defaultSynthesize example,
  and updated the README guardrails section.

Added tests for option validation, empty-task rejection, and onEvent
isolation. 21 tests pass.
@suleimansh suleimansh added the enhancement New feature or request label Jun 26, 2026
@suleimansh suleimansh self-assigned this Jun 26, 2026
@suleimansh suleimansh merged commit 81fe17b into main Jun 26, 2026
1 check passed
@suleimansh suleimansh deleted the quality/ai-autopilot branch June 26, 2026 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant