Skip to content

v12.0.0 — promise-based fly(), typed errors, landing rewrite, tests + CI - #1

Merged
arena-ai-coding-agent[bot] merged 5 commits into
devfrom
arena/01a0c536-eafe
Sep 22, 2026
Merged

arena-ai-coding-agent[bot] merged 5 commits into
devfrom
arena/01a0c536-eafe

Conversation

@arena-ai-coding-agent

Copy link
Copy Markdown

v12.0.0 — promise-based API, typed errors, rewrite of landing & reliability

Companion to the two audit rounds: all confirmed bugs (B1–B25, A1–A9) fixed, plus the missing repo infrastructure (tests, lint, CI, license, changelog). 27/27 tests passing (zero-dependency mock-flight suite, ~40 s).

Breaking (12.0.0)

  • fly() returns a Promise — resolves { phase: 'IDLE', landedAt: {x,y,z} }, rejects ElytraFlightError with a machine-readable err.code (19 codes; see README table). Branch on err.code, never message text.
  • fly() during CRUISE/DEADSTICK retargets in place and returns the same pending promise; any other in-flight phase rejects IN_FLIGHT and does not change the active target.
  • Deterministic pre-flight failures (NO_ENTITY, NO_ELYTRA, ELYTRA_LOW, NO_ROCKETS, NO_LAUNCH_SPOT, PF_FAILED) fail fast with their code; transient in-flight failures retry up to maxRetries, then reject RETRIES_EXHAUSTED with the last code in err.cause.
  • Landing rewritten: spiral orbit → glide-to-goal onto a verified safe spot; hazard (cactus) touchdown relocates instead of looping forever.
  • Removed src/commands.js, src/config.js, src/core/chat.js — chat commands were never part of the flight engine; owner alerts are whisper-only.

Added

  • New DEADSTICK phase — fuel-out mid-climb/cruise glides to the goal and still lands (covered by an integration test).
  • src/errors.js — frozen 19-code error set, typed error class, NON_RETRYABLE set.
  • test/ — zero-dependency suite (node test/run.js): mock mineflayer bot over real prismarine-world 1.21 terrain with blocks/tick elytra physics; 14 unit + 13 integration tests (full 300 m flight, retarget, stop semantics, retry exhaustion, elytra swap, cactus/flower recovery, fuel-out) + perf guard (< 500k blockAt calls per flight, ~45k in practice).
  • Lint (ESLint 9 flat config; npm run lint over src/test/examples — clean), CI (.github/workflows/ci.yml, Node 18/20/22: ci → lint → tests → pack dry-run), LICENSE (MIT), CHANGELOG.md.

Fixed (selection — full list in CHANGELOG)

  • emit('error') no longer throws synchronously when no listener is attached (guarded; the promise rejection is the primary path).
  • stop() clears the real interval handles (fly/verify/rocket/climb/land loops + retry/sneak timers), emits exactly one stopped, and cancels a pending retry (no more re-takeoff after stop).
  • _yawTo dead zone: within 3 m of the target column the bearing is numerically unstable (jitter flipped it ~180° → bot spun and never fired rockets).
  • Per-module ctx.state copies (writes silently lost) → single shared state object; per-instance logger (no more shared debug state across bots).
  • Takeoff fires its first rocket before the isFlying() check (an elytra at jump apex is already isFlying() with zero boost).
  • Mode aliases MED/LOW resolve instead of silently falling back to MED; unknown mode no longer resets to MED.
  • preflight() is pure (no equip side effect) and always returns the documented shape.

Changed

  • All 11 examples promise-driven (.then/.catch, STOPPED-aware), public-API only, with re-entrancy guards in the queue-based ones.
  • landingMargin default 2 → 1; mode planning speeds documented (22/13/10 m/s).
  • legacy/elytraBot.js untracked (kept on disk) — pre-12 monolith is reference-only.

eksses and others added 5 commits September 22, 2026 17:38
Breaking API changes:
- fly() now returns a Promise: resolves { phase, landedAt } on landing,
  rejects ElytraFlightError (err.code) on failure/stop/respawn
- 19 error codes in src/errors.js; NON_RETRYABLE pre-flight failures
  (NO_ENTITY/NO_ELYTRA/ELYTRA_LOW/NO_ROCKETS/NO_LAUNCH_SPOT/PF_FAILED)
  fail fast, transient in-flight failures retry -> RETRIES_EXHAUSTED
  with the last code in err.cause
- fly() during CRUISE/DEADSTICK retargets the active flight and returns
  the same pending promise; any other in-flight phase rejects IN_FLIGHT
  without touching the active target
- emit('error') guarded (no more synchronous throw with no listener);
  the promise rejection is the primary error path

Rewrites & fixes:
- Landing: spiral orbit -> glide-to-goal onto a verified safe spot;
  cactus/hazard touchdown now relocates instead of looping forever
- New DEADSTICK phase: fuel-out mid-climb/cruise glides to the goal
- _yawTo holds heading within 3 m of the target column (jitter dead zone
  that made the bot spin and stall)
- stop() clears the real interval handles (fly/verify/rocket/climb/land
  loops + retry/sneak timers), emits exactly one 'stopped', cancels a
  pending retry, rejects the promise with STOPPED
- Single shared state object (per-module ctx.state copies are gone);
  per-instance logger; module switches (safety/elytraAudit/autoRocket/
  chunkScan/pathfinding/wander/landing) all honoured
- Removed src/commands.js, src/config.js, src/core/chat.js (chat
  commands moved out of the engine, owner alerts via whisper only)
- MODES.MED/LOW aliases resolve; mode speeds 22/13/10 m/s (planning)

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
- test/run.js: parallel unit + integration runner, real-time budget,
  zero npm dependencies (node test/run.js, unit, integ)
- test/helpers/mock-bot.js: mineflayer bot over a real prismarine-world
  1.21 terrain with blocks/tick elytra physics (rocket boost decay,
  ~15:1 glide, stall on up-point without boost) — yaw convention
  verified against mineflayer's own bot.lookAt
- 14 unit tests: mode/phase/error-code invariants, block
  classification against real 1.21 data, elytra damage math
  (2/(n+3), unbreaking-aware), rocket counting/requirements
- 13 integration tests: full 300 m flight, IN_FLIGHT + mid-cruise
  retarget (same promise), stop() semantics (one 'stopped',
  pending-retry cancellation), NO_ENTITY, RETRIES_EXHAUSTED with
  err.cause, preflight purity/shape, worn-elytra swap, flower/cactus
  landing recovery, DEADSTICK fuel-out landing
- perf guard: 300 m flight < 500k blockAt calls (~45k in practice)

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
- Every fly() call now chains .then/.catch (STOPPED-aware); no more
  fire-and-forget flights or phase-event queue watching (IDLE double-
  fires on stop, which made queues double-advance)
- inventory-transfer.js: removed the IDLE-driving phase listener;
  all three legs chain to handleTransferArrival(); transferMode
  re-entrancy guard on the transfer commands
- waypoint-travel.js: next waypoint chained in .then(); waypointMode
  re-entrancy guard; .then/.catch on the chat commands
- advanced/demo/multi-bot one-shot flights got .then/.catch
- Dropped private internals (flight._targetX/_targetZ) for the public
  flight.targetX/targetZ getters

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
- LICENSE: MIT (eksses, 2024-2026); CHANGELOG.md: 12.0.0 entry
- eslint flat config (ESLint 9 + @eslint/js); npm run lint covers
  src, test, examples — clean
- .github/workflows/ci.yml: node 18/20/22 — npm ci, lint,
  node test/run.js, npm pack --dry-run
- package.json: v12.0.0, files includes LICENSE, eslint devDeps
- legacy/elytraBot.js untracked (kept on disk, gitignored) — pre-12
  monolith is reference-only and no longer part of the package

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
- Promise-based fly() in Quick Start / API / all examples
- Full constructor options block (module switches, reliability,
  hazardCheck, landingMargin default 1)
- Error-code table (19 codes, fail-fast vs retried, err.cause)
- Phases: string values (FAIL, SCAN, RELOC), DEADSTICK, glide-to-goal
  landing; mode planning speeds 22/13/10
- Development section: node test/run.js, npm run lint, CI
- AGENTS.md: v12 architecture, critical invariants learned from real
  bugs (yaw convention, _yawTo dead zone, takeoff-first fire,
  guarded emit('error'), run-until-settled), mock physics gotchas,
  measured rocket requirements

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @arena-ai-coding-agent[bot], your pull request is larger than the review limit of 150,000 diff characters

@coderabbitai

coderabbitai Bot commented Sep 22, 2026

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 9f9bd2f3-270c-4970-9156-8cd92ff4488a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@arena-ai-coding-agent
arena-ai-coding-agent Bot merged commit 66cb899 into dev Sep 22, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant