Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
7c4ee2e
Add unit tests for intelligence lifecycle, loader order, metrics, mod…
mCodex Jul 17, 2026
86b79ac
Refactor unit tests for containers and intelligence modules to align …
mCodex Jul 17, 2026
a0fb85b
refactor: Remove legacy HuntAnalyzer and Monster Inspector, transitio…
mCodex Jul 17, 2026
62b83a5
fix: intelligence summary
mCodex Jul 20, 2026
3258958
chore: cleaning up code
mCodex Jul 20, 2026
c3a08ff
feat(intelligence): add outcome_reasons module with ClosureReason enum
mCodex Jul 20, 2026
b02286c
feat(intelligence): add event_schema.lua with 25 canonical event types
mCodex Jul 20, 2026
02012dc
Add IntelligenceEventFactory with TDD tests (Task 0.3)
mCodex Jul 20, 2026
ee05633
feat(intelligence): add LRU event deduplicator
mCodex Jul 20, 2026
b03d6a7
fix: remove duplicate EventBus registrations in tactical_intelligence
mCodex Jul 21, 2026
b9f12f4
feat(intelligence): add OutcomeRecord for decision outcome tracking
mCodex Jul 21, 2026
cb65907
feat(intelligence): add DecisionRecord for ML decision tracking
mCodex Jul 21, 2026
72f7f50
feat(intelligence): add episode_base.lua with lifecycle management
mCodex Jul 21, 2026
cfe69c9
Add encounter_tracker module with TDD tests
mCodex Jul 21, 2026
c413e0c
feat: add route_segment_tracker and hunt_tracker episode modules
mCodex Jul 21, 2026
f6749c5
Add loot episode tracker (Task 1.5)
mCodex Jul 21, 2026
0a49f32
Wire episode trackers into intelligence runtime
mCodex Jul 21, 2026
99cfd3a
Add resource_cost module for action cost tracking
mCodex Jul 21, 2026
bf74c18
fix: loot observer emits canonical events via IntelligenceEventFactory
mCodex Jul 21, 2026
c345e58
Add item_value_provider for loot value estimation (Task 2.2)
mCodex Jul 21, 2026
e4baddf
feat: add reward_vector.lua — versioned multi-objective reward vector
mCodex Jul 21, 2026
e0c0c59
Add reward_normalizer for stable training (Task 3.2)
mCodex Jul 21, 2026
64aa6fb
Wire reward system into intelligence runtime
mCodex Jul 21, 2026
83ee80f
add intelligence model interface v2 with mode-gated predict/observe
mCodex Jul 21, 2026
d978d91
Add CANARY mode to model registry
mCodex Jul 21, 2026
2090a49
Replace 12 alias Bayesian models with 7 genuine contextual models
mCodex Jul 21, 2026
3672918
feat: add decision_log.lua for offline evaluation (Task 5.1)
mCodex Jul 21, 2026
1824f41
feat: add confidence interval calculator (Task 5.4)
mCodex Jul 21, 2026
de59251
Add promotion_report.lua with 17-gate promotion evaluation
mCodex Jul 21, 2026
ba2c55b
feat: add replay evaluator for offline decision evaluation (task 5.2)
mCodex Jul 21, 2026
3206090
feat: add kill_switch.lua for emergency ML disable
mCodex Jul 21, 2026
e2bc79f
feat: add adjustment bounds enforcer for canary bounded integration
mCodex Jul 21, 2026
953dbe9
Add rollback monitor guardrail with threshold checks
mCodex Jul 21, 2026
f4d3e2f
feat(7.1): conservative reranker with bounded model adjustments
mCodex Jul 21, 2026
cb0d9d9
feat: add target switch guard to prevent target thrashing
mCodex Jul 21, 2026
cf61bed
Wire TargetBot and CaveBot guardrails into intelligence runtime
mCodex Jul 21, 2026
49a045c
feat: add loot_priority module (Task 8.1)
mCodex Jul 21, 2026
06ffd79
Wire loot priority into intelligence runtime
mCodex Jul 21, 2026
5489b4e
feat(intelligence): add decision explainer for human-readable decisio…
mCodex Jul 21, 2026
4719fe5
wire decision explainer into intelligence runtime
mCodex Jul 21, 2026
45e8727
fix: update runtime references from old model names to new catalog
mCodex Jul 21, 2026
40d64ce
fix: add new intelligence modules to _Loader.lua
mCodex Jul 21, 2026
8029bd4
fix: add missing nExBot registration to reward_vector, item_value_pro…
mCodex Jul 21, 2026
88eddae
fix: table.unpack -> unpack for Lua 5.1/LuaJIT compatibility
mCodex Jul 21, 2026
12fe98c
fix: replace unpack with manual copyArray for OTClient compat
mCodex Jul 21, 2026
3d4cd18
fix: AI data
mCodex Jul 24, 2026
045f90f
chore: added funding
mCodex Jul 24, 2026
2026b17
chore: improving AI module and fixing tests
mCodex Jul 24, 2026
219bdfb
fix: tests
mCodex Jul 24, 2026
90229f4
feat(phase1): add domain enums, combat frame recorder, characterizati…
mCodex Jul 31, 2026
ceeaaf6
feat(phase2): add ReachabilityService with evidence accumulation and …
mCodex Jul 31, 2026
b9bd8a3
feat(phase2): add AttackFSM (8 states, generation tokens) and TargetC…
mCodex Jul 31, 2026
6051d71
fix(phase2): wire Phase 2 into main loop — fix primary target abandon…
mCodex Jul 31, 2026
f375e4f
feat(phase3): add tactical planners — Lure, DynamicLure, Pull, Reposi…
mCodex Jul 31, 2026
18f15bb
feat(phase4+5): add FeatureArbitrator, MovementArbitrator, and 5 cont…
mCodex Jul 31, 2026
d9db6ba
test(phase6): add integration, property-based, soak, and performance …
mCodex Jul 31, 2026
4731728
docs: add v5 architecture document
mCodex Jul 31, 2026
e9b8afb
fix: add early TargetBot.isOff stub to prevent nil errors in EventBus…
mCodex Jul 31, 2026
764999f
fix: remove _G reference in target_commitment.lua (OTClient sandbox)
mCodex Jul 31, 2026
5a12c20
fix: restore analyzer.otui and smart_hunt.otui deleted by premature c…
mCodex Jul 31, 2026
2c8a5b6
Refactor intelligence UI and attack state management
mCodex Jul 31, 2026
3ce9eeb
Add unit tests for TransitionCoordinator and WP26 fixture; refactor p…
mCodex Aug 5, 2026
890083c
chore: working on bot improvement
mCodex Aug 24, 2026
9a41276
chore: improving codebase
mCodex Aug 24, 2026
4baeec8
chore: working on code cleaning up
mCodex Aug 24, 2026
59e8c4e
chore: code cleanup
mCodex Aug 24, 2026
2a6c6fe
chore: cleaning up code
mCodex Aug 24, 2026
7039b27
chore: refactoring UI handlers
mCodex Aug 25, 2026
aefeb4f
chore: working on bot's UI
mCodex Aug 25, 2026
99dd541
chore: cleaning up UI
mCodex Aug 25, 2026
320b3dc
fix: UI freeze
mCodex Aug 25, 2026
d8498b0
chore: working on UI
mCodex Aug 25, 2026
3a9ba20
chore: cleaning up code
mCodex Aug 25, 2026
ae77ee8
chore: refactoring UI
mCodex Aug 26, 2026
fa2cec8
docs: define nexbot reliability redesign
mCodex Aug 31, 2026
8ad44a5
docs: plan nexbot reliability redesign
mCodex Aug 31, 2026
6052b08
fix: unify combat ownership for cavebot
mCodex Aug 31, 2026
1d1bc71
fix: make cavebot waypoint approaches transition-aware
mCodex Aug 31, 2026
637f1b3
refactor: share bounded nexbot UI components
mCodex Aug 31, 2026
7ac5871
fix: recover stale attack state after reconnect
mCodex Aug 31, 2026
97a087f
fix: harden cavebot route safety
mCodex Aug 31, 2026
9becba6
chore: cleaning up code
mCodex Aug 31, 2026
1666084
fix: targetbot
mCodex Aug 31, 2026
556670d
cavebot: session-tick GPS driver behind sessionNav kill-switch (Phase 1)
mCodex Aug 31, 2026
ce2e6ec
cavebot: session-driver route-completion + round-trip test (Phases 2-3)
mCodex Sep 1, 2026
0567d48
cavebot: flip sessionNav default ON + retry-escalation escape hatch (…
mCodex Sep 1, 2026
1755426
cavebot: fix session_driver 'module not found' at runtime
mCodex Sep 1, 2026
a61ebdc
revert(cavebot): drop session GPS driver, drive movement natively via…
mCodex Sep 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
15 changes: 15 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# These are supported funding model platforms

github: [mcodex]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
polar: # Replace with a single Polar username
buy_me_a_coffee: # Replace with a single Buy Me a Coffee username
thanks_dev: # Replace with a single thanks.dev username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
*configs
storage/
private/
private/
.tokensave
node_modules/
6 changes: 5 additions & 1 deletion .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ max_line_length = 120
read_globals = {
-- OTClient core
"g_game", "g_map", "g_ui", "g_things", "g_clock", "g_resources", "g_platform", "g_http", "HTTP",
"modules", "macro", "schedule", "dofile", "periodic",
"modules", "macro", "schedule", "dofile", "periodic", "g_items",
"now", "autoWalk",

-- Player accessors
"pos", "target", "player", "mana", "hppercent", "manapercent",
Expand All @@ -23,6 +24,7 @@ read_globals = {
-- Native callback registration (all optional, may not exist)
"onCreatureAppear", "onCreatureDisappear", "onCreatureHealthPercentChange",
"onPlayerPositionChange", "onManaChange", "onHealthChange",
"onPlayerZChange", "onPlayerWalkError",
"onContainerOpen", "onContainerClose", "onContainerUpdateItem",
"onAttackingCreatureChange", "onTextMessage", "onTalk",
"onAddThing", "onRemoveThing", "onWalk", "onTurn", "onMissle",
Expand Down Expand Up @@ -51,6 +53,8 @@ globals = {
"ZChangeGuard", "KillTracker",
"AttackData", "AttackAnalytics", "AttackConfig", "CombatExecutor",
"HealConfig", "SpellResolver", "HealAnalytics",
"Supplies", "BotDB", "AttackFSM", "MovementCoordinator",
"IntelligenceBotDoctor", "IntelligenceUiPresenter",
"storage", "info", "warn",
}

Expand Down
70 changes: 70 additions & 0 deletions .superpowers/sdd/route-safety-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Route Safety Report

## Scope

Implemented the wall-traversal route-safety slice only. Unrelated UI, combat,
and existing user worktree changes were not modified.

## Findings Fixed

- `StepValidator.canMergeDiagonal` checked only the traversed cardinal tile and
diagonal destination. It now checks both orthogonal corner tiles.
- `PathStrategy.findPath` accepted malformed or wall-crossing native direction
arrays. Every returned direction is now structurally and geometrically
validated, including diagonal corners and destination walkability.
- `PathStrategy.nativePathIsSafe` stopped checking after an invalid direction
and could dereference missing tile helpers. It now fails closed.
- CaveBot's field loop called raw `walk(d)`. It now validates each exact step
and dispatches through `PathStrategy.walkStep`.
- CaveBot used keyboard nudge and relaxed searches after strict path failure.
Those unsafe fallback paths were removed; strict failure returns `false`.
- The OTBR adapter dropped `maxSteps` and shifted the options argument. Its
`autoWalk(destination, maxSteps, options)` forwarding now matches callers.

## TDD Evidence

Failing focused run before implementation:

```text
15 successes / 5 failures / 0 errors / 0 pending
```

Failures covered diagonal corner rejection, native path validation, raw field
walking, and OTBR argument forwarding.

Passing focused run after implementation:

```text
38 successes / 0 failures / 0 errors / 0 pending
```

Command:

```text
busted tests/unit/navigation/step_validator_spec.lua \
tests/unit/navigation/route_safety_spec.lua \
tests/unit/navigation/path_planner_spec.lua \
tests/unit/navigation/obstacles_spec.lua
```

`git diff --check` passed.

## Verification Limitation

The focused `luacheck` command could not start because the installed Luacheck
1.2.0 loader is incompatible with the installed Lua 5.5 runtime:

```text
luacheck/standards.lua:134: attempt to assign to const variable 'field_name'
```

No code lint result is claimed from that command.

## Changed Files

- `cavebot/walking.lua`
- `utils/path_strategy.lua`
- `core/acl/adapters/opentibiabr.lua`
- `navigation/step_validator.lua`
- `tests/unit/navigation/step_validator_spec.lua`
- `tests/unit/navigation/route_safety_spec.lua`
58 changes: 58 additions & 0 deletions .superpowers/sdd/task-5-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Task 5 Report

## Result

Implemented attack synchronization and lifecycle recovery without changing UI,
navigation, CaveBot, or the legacy `AttackStateMachine`.

## Root cause

`AttackFSM` treated `pcall` success as a successful native attack, so a native
`attack()` returning `false` was accepted. Same-target requests also returned
success without dispatch, and `LOCKED` refreshed confirmation from the stale
red-square selection on every tick. Disappearance had no authoritative FSM
path and could be counted as a kill by the active attack flow.

## Changes

- `targetbot/application/attack_fsm.lua`
- Separates selected target, command dispatch, client confirmation, and health progress evidence.
- Rejects explicit false native attack returns.
- Re-dispatches same targets after connection-generation invalidation.
- Adds `isProgressing()` and `onConnectionGeneration()`.
- Adds bounded `STALLED` recovery at 200 ms, 1 s, and 3 s, then releases.
- Adds disappearance and health-progress event entry points.
- Keeps disappearance from incrementing kill statistics.
- `targetbot/target_events.lua`
- Routes target disappearance and health progress to the authoritative FSM.
- `targetbot/target_coordinator.lua`
- Wires game/login/logout and recovery-pause generations to FSM invalidation.
- `tests/unit/domain/attack_fsm_spec.lua`
- Adds regression coverage for false returns, reconnect recovery, stale selection, progress evidence, bounded retries, and disappearance.

## TDD evidence

Initial focused run before implementation:

```text
23 successes / 2 failures / 2 errors
```

The failures were the expected missing behaviors: false attack accepted,
missing `onConnectionGeneration`, missing `isProgressing`, and stale state
transitions.

Final focused run:

```text
busted tests/unit/domain/attack_fsm_spec.lua tests/integration/combat_pipeline_spec.lua tests/integration/target_abandonment_spec.lua
29 successes / 0 failures / 0 errors / 0 pending
```

## Self-review

- No files outside the requested target files, listed tests, and report were staged.
- `core/client_lifecycle.lua` was unchanged because its existing generation callback contract was sufficient.
- Native confirmation is no longer refreshed merely because the red square remains selected.
- Recovery is timer-bounded and does not retry on every tick.
- Unrelated pre-existing UI, navigation, and CaveBot changes remain untouched.
102 changes: 68 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# nExBot

![Version](https://img.shields.io/badge/version-4.0.0-blue)
![Version](https://img.shields.io/badge/version-5.1.0-blue)
![License](https://img.shields.io/badge/license-MIT-green)
![Lua](https://img.shields.io/badge/Lua-5.1-purple)

Expand All @@ -16,19 +16,67 @@ Install paths:
- **vBot:** `%APPDATA%/OTClientV8/<ServerName>/bot/nExBot`
- **OTCR:** `~/.local/share/<otcr-data>/<ServerName>/bot/nExBot`

## v5.1.0 — Tactical Intelligence, Profile Reconnect & Character-Bound State Remediation

This release delivers a comprehensive remediation of state management, persistence, and tactical intelligence:

- **Atomic profile switching** — CaveBot/TargetBot profile changes preserve desired ON/OFF state, commit in single transaction
- **Character-bound state** — Per-character, per-root-profile UnifiedStorage files (schema v6), full isolation
- **Tactical Intelligence crash safety** — `next = nil` sandbox handled, section isolation, incremental projections
- **Analytics contract separation** — `TelemetryClient` (outbound), `HuntMetrics` (local), `ClientTelemetry` (OTClient signals)
- **Desired vs Effective state** — Explicit inhibitors, runtime state never overwrites user preference
- **Explicit origins** — Every mutation carries `USER`/`INITIAL_RESTORE`/`RECONNECT_RESTORE`/etc.
- **Silent restoration** — UI restores without triggering persistence callbacks
- **Control registry** — All toggles declaratively registered with explicit scopes
- **Lifecycle adapter** — `onGameStart`/`onGameEnd` drive state coordinator, generation guards on all async work
- **Performance** — ≥70% Tactical CPU reduction target, no-change projection p95 <2ms

## v5 UI Platform

nExBot v5 introduces a unified product interface built on one design system,
one navigation shell, and one shared component library.

- **BotShell** — replaces the client's left bot bar with a compact cockpit
containing engine controls, telemetry, attention state, and a footer.
Single instance, generation-guarded lifecycle, auto-attaches to the host
left panel at startup.
- **ModuleRegistry** — secondary-page navigation and ordering.
- **Design system** — semantic color/spacing/typography/density/status tokens
(`ui/design_system/`), frozen against mutation.
- **Icons** — native Tibia item sprites through `UIItem`; no asset toolchain.
- **Components** — shared widget library (`ui/components/`).
- **View models** — embedded workflows expose versioned projections
(`schemaVersion, revision, state, header, sections, actions`); widgets never
mutate domain globals directly.

The shell replaces the legacy tab-fill left bar.

## Modules

| Module | Function |
|--------|----------|
| **HealBot** | Spell/potion healing at configurable HP thresholds. 75ms response. |
| **AttackBot** | Attack spell/rune rotation with AoE optimization |
| **CaveBot** | Waypoint navigation, floor-change safety, supply refills, 50+ pre-built routes |
| **TargetBot** | 9-stage priority targeting, Monster Insights AI, movement coordination |
| **Hunt Analyzer** | Session analytics — kills/hr, XP/hr, profit, Hunt Score |
| **Containers** | Event-driven BFS, O(1) operations, generation tracking, quiver management 🎒 |
| **TargetBot** | 9-stage priority targeting, Tactical Intelligence integration, movement coordination |
| **Tactical Intelligence** | Unified session analytics, monster intelligence, targeting history, resources, routes |
| **Containers** | Event-driven BFS, O(1) operations, generation tracking, reconnect recovery coordinator, multi-level readiness, quiver management 🎒 |
| **Follow Player** | Party hunt — stays near leader while attacking |
| **Extras** | Anti-RS, alarms, equipment swap, combo system, push max |

## Adaptive Intelligence

nExBot shares combat and navigation context through one bounded intelligence runtime:

- TargetBot evaluates candidates through deterministic proposal arbitration and a hard safety envelope.
- Dynamic Lure, Pull, and wave avoidance use explicit state machines.
- CaveBot preserves route intent across combat pauses, path failures, and recovery.
- Twelve local models learn in `SHADOW` mode without changing actions.
- Replay, calibration, resource tracking, learned navigation costs, and Bot Doctor diagnostics use bounded storage.
- Adaptive tick rates reduce background work while combat and safety paths keep their priority.

Open **More → Analytics → AI Intelligence** to inspect lifecycle, targeting, routes, models, replay, resources, and diagnostics.

## Architecture

```
Expand All @@ -37,17 +85,23 @@ Install paths:
├── EventBus (event-driven communication)
├── UnifiedTick (single 50ms master timer)
├── UnifiedStorage (per-character JSON persistence)
├── Adaptive Intelligence
│ ├── immutable world snapshot + feature pipeline
│ ├── proposal arbitration + hard safety envelope
│ ├── bounded SHADOW models, replay, calibration, and diagnostics
│ └── adaptive tick and optional-work budgets
├── Containers 🎒
│ ├── identity (physical container identity)
│ ├── identity (physical container identity — generation+path+slot+type)
│ ├── queue (head/tail FIFO, O(1) dequeue)
│ ├── state_machine (13 states, generation tracking)
│ ├── registry (O(1) lookups, incremental item index)
│ ├── bfs (event-driven traversal)
│ ├── scheduler (UnifiedTick integration)
│ ├── readiness (derived snapshots)
│ ├── quiver (paladin ownership)
│ └── discovery (orchestrator)
│ ├── state_machine (23 states, generation tracking, transition log)
│ ├── registry (O(1) lookups, slot-level item index, role assignments)
│ ├── bfs (event-driven traversal, retry counting, deduplication)
│ ├── scheduler (priority queue, ack timeout, exhaustion backoff)
│ ├── readiness (10-level derived snapshots)
│ ├── client_adapter (OTClient/vBot abstraction)
│ ├── quiver (paladin ownership, fixed slot detection)
│ └── discovery (orchestrator + reconnect recovery coordinator)
├── HealBot ←── player:health events
│ └── spell_resolver (conversion functions)
Expand All @@ -57,33 +111,13 @@ Install paths:
├── CaveBot ←─── 250ms waypoint engine
├── TargetBot ←─ creature events + Monster AI
│ ├── AttackStateMachine (sole attack issuer)
│ ├── Monster Insights (12 AI modules)
│ └── MovementCoordinator (intent voting)
└── Hunt Analyzer ←─ passive analytics
│ └── Tactical Intelligence ←─ unified analytics + learning
```

## Documentation

| Guide | Description |
|-------|-------------|
| [Installing](docs/INSTALLING.md) | Installation for vBot and OTCR |
| [HealBot](docs/HEALBOT.md) | Healing spells, potions, conditions |
| [AttackBot](docs/ATTACKBOT.md) | Attack spells, runes, AoE optimization |
| [CaveBot](docs/CAVEBOT.md) | Navigation, waypoints, supply management |
| [TargetBot](docs/TARGETBOT.md) | Combat AI, Monster Insights, movement |
| [Follow Player](docs/FOLLOW.md) | Party hunt companion |
| [Containers](docs/CONTAINERS.md) | Container management, quiver system |
| [Hunt Analyzer](docs/SMARTHUNT.md) | Session analytics |
| [Extras](docs/EXTRAS.md) | Safety, equipment, utilities |
| [Architecture](docs/ARCHITECTURE.md) | Technical design |
| [Performance](docs/PERFORMANCE.md) | Optimization and tuning |
| [FAQ](docs/FAQ.md) | Troubleshooting |

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md). Run `make check` before submitting. Follow existing Lua style (2-space indentation).

## License

[MIT License](LICENSE)
MIT License.
Loading