Skip to content

Feat/quick wins and roadmap#12

Merged
JuanMarchetto merged 5 commits intomainfrom
feat/quick-wins-and-roadmap
Mar 3, 2026
Merged

Feat/quick wins and roadmap#12
JuanMarchetto merged 5 commits intomainfrom
feat/quick-wins-and-roadmap

Conversation

@JuanMarchetto
Copy link
Collaborator

No description provided.

Fix 1+2 — solve_time_ms now measured via Instant::now() around the
solver call; metadata.seed echoes the submitted seed value back to
callers for auditability.

Fix 3 — Problem::validate() extended with time-window, demand sign,
coordinate range, fleet_size, vehicle.capacity and shift-window checks.
submit-problem handler calls validate() before accepting, returning
HTTP 400 with a structured error message on failure.

Fix 4 — client owner_id persisted in localStorage ('loxi_owner_id')
via useMemo so it survives tab refresh without changing.

Fix 5 — PushSolution ticket verification wired end-to-end: LogisticsArchitect
gains a verify_fn field; run_architect() accepts the closure; main.rs
passes the existing verify_ticket Arc; PushSolution handler rejects
submissions with an invalid ticket instead of silently accepting them.

Fix 6 — Multi-vehicle fleet support: FleetVehicle struct added to
types.rs with type_id, count, capacity, speed_mps, locations, shift
window and cost fields. Optional fleet field added to Problem.
to_pragmatic() builds one VehicleType per FleetVehicle entry when fleet
is present, falling back to the existing single-vehicle path. Fleet is
propagated through all sub-problem construction sites in the architect.

Fix 7 — README: replace "auction" with "dispatch" in user-facing
architecture diagram and prose; rephrase "Workers bid on tasks" to
reflect the actual scheduler behaviour.

Fix 8 — Overflow rescue partitions get a prefixed task ID
(overflow_rescue_<uuid>); final solution assembly detects them and
populates solution.violations with type="overflow_rescue" and
magnitude=stop_count so callers can surface the warning.

README — Roadmap section added (near-term / medium-term / long-term)
covering multi-fleet, reproducible solves, geocoding, webhooks, OpenAPI,
WebRTC P2P, real competitive auction and on-chain settlement.
…tecture

Group 1 — Trivial cleanup:
- Remove hardcoded 192.168.0.196 IP fallback from SDK
- Randomize RNG seed (Date.now() * Math.random()) in both loadUpload + generateProblem
- Latency-inverse bidding score: 1_000_000 / max(taskDuration, 1)
- Dynamic depot centroid from stop data instead of hardcoded Buenos Aires
- Polling timeout now emits error log after 10 minutes
- owner_id uses crypto.randomUUID() for high-entropy IDs
- process_solution returns early with eprintln on unknown auction_id
- Matrix guard: && → || so either missing matrix rejects the solve
- WS payload size limit: drop messages > 1 MiB in orchestrator

Group 2 — Focused fixes:
- format_time: Fliegel-Van Flandern proleptic Gregorian; base epoch 2025-01-01
- JWT aud claim validation: verify_fn now returns Option<(sub, aud)>; ClaimTask
  and PushSolution handlers compare aud == auction_id before accepting
- Demand/capacity f64 casts: .round() as i32 + eprintln warning on fractional values
- pending_problems eviction: DashMap timestamp per problem; background task
  evicts solved problems older than 2 h every 10 minutes

Group 3 — Reliability:
- revealingSolution: 3 attempts with 2s/4s/8s backoff; waits for {"ack":"ok"}
  with 5 s timeout per attempt; logs CRITICAL on exhaustion
- server.rs PushSolution path sends {"ack":"ok"} after protocol_tx.send
- Sweep panicking unwrap/expect from architect event loop; use let-else / if-let

Group 4 — Architecture:
- SEARCH_DEPTH: 5 → 20
- O(1) watchdog reverse index: worker_to_auction HashMap in Scheduler; used
  in drain_expired and disconnect handler (replaces O(N) DashMap scans)
- LogisticsArchitect now guarded by tokio::sync::Mutex; distribute_tasks
  runs H3 partition work via spawn_blocking off the async thread
- cargo fmt: auto-format 5 files (architect/mod.rs, vrp/mod.rs,
  types.rs, lib.rs, loxi-orchestrator/lib.rs)
- Add VerifyFn type alias in loxi-logistics lib.rs to satisfy
  clippy::type_complexity on the verify_fn Arc<dyn Fn> field
- Use VerifyFn alias in architect/mod.rs, server.rs, bin/client.rs,
  loxi-cli/main.rs
- Fix pre-existing noImplicitAny TS errors in App.tsx exportSolution
  (add explicit string/number types to forEach/map callbacks)
Scheduler tests (7 new):
- affinity worker beats higher-score generic worker (tier-2 vs tier-3)
- hardware fallback when no affinity match (dynamic loading path)
- undersized worker queues task instead of assigning
- worker_to_auction reverse index populated on schedule
- reverse index cleared on release
- drain_expired returns (worker_id, Some(auction_id)) pair
- queued task pipes immediately to next available worker

Auth tests (5 new):
- sign/verify round trip (sub + aud preserved)
- aud claim matches auction_id passed to sign_ticket
- invalid token rejected
- empty public key blocks verify
- token signed with key A rejected by key B

SDK (item 2):
- npm install in sdk/web — tsup was in devDependencies but not installed;
  npm run build now produces dist/index.js, dist/index.mjs, dist/index.d.ts
@JuanMarchetto JuanMarchetto merged commit 0d5e373 into main Mar 3, 2026
2 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