@jsm-mit/tigi-sharded-package 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +88 -2
  2. package/declarations/coordinator/coordinator.did +624 -0
  3. package/declarations/coordinator/coordinator.did.d.ts +956 -0
  4. package/declarations/coordinator/coordinator.did.js +406 -0
  5. package/declarations/core/core.did +420 -0
  6. package/declarations/core/core.did.d.ts +344 -0
  7. package/declarations/core/core.did.js +291 -0
  8. package/declarations/tigi-driver/tigi-driver.did +201 -0
  9. package/declarations/tigi-driver/tigi-driver.did.d.ts +165 -0
  10. package/declarations/tigi-driver/tigi-driver.did.js +117 -0
  11. package/declarations/tigi-simulator/tigi-simulator.did +300 -0
  12. package/declarations/tigi-simulator/tigi-simulator.did.d.ts +417 -0
  13. package/declarations/tigi-simulator/tigi-simulator.did.js +177 -0
  14. package/declarations/worker/worker.did +453 -0
  15. package/declarations/worker/worker.did.d.ts +399 -0
  16. package/declarations/worker/worker.did.js +348 -0
  17. package/dist/actors/profiles-actor.d.ts +33 -0
  18. package/dist/actors/profiles-actor.d.ts.map +1 -0
  19. package/dist/actors/profiles-actor.js +67 -0
  20. package/dist/actors/rides-actor.d.ts +216 -0
  21. package/dist/actors/rides-actor.d.ts.map +1 -0
  22. package/dist/actors/rides-actor.js +549 -0
  23. package/dist/actors/test-manager-actor.d.ts +37 -0
  24. package/dist/actors/test-manager-actor.d.ts.map +1 -0
  25. package/dist/actors/test-manager-actor.js +64 -0
  26. package/dist/geo.d.ts +18 -0
  27. package/dist/geo.d.ts.map +1 -0
  28. package/dist/geo.js +132 -0
  29. package/dist/group/canister-actor.d.ts +94 -0
  30. package/dist/group/canister-actor.d.ts.map +1 -0
  31. package/dist/group/canister-actor.js +182 -0
  32. package/dist/group/group.d.ts +63 -0
  33. package/dist/group/group.d.ts.map +1 -0
  34. package/dist/group/group.js +120 -0
  35. package/dist/group/prefixes.d.ts +14 -0
  36. package/dist/group/prefixes.d.ts.map +1 -0
  37. package/dist/group/prefixes.js +26 -0
  38. package/dist/group-entry.d.ts +3 -0
  39. package/dist/group-entry.d.ts.map +1 -0
  40. package/dist/group-entry.js +5 -0
  41. package/dist/index.d.ts +7 -0
  42. package/dist/index.d.ts.map +1 -0
  43. package/dist/index.js +12 -0
  44. package/dist/interfaces.d.ts +149 -0
  45. package/dist/interfaces.d.ts.map +1 -0
  46. package/dist/interfaces.js +5 -0
  47. package/dist/mappers.d.ts +70 -0
  48. package/dist/mappers.d.ts.map +1 -0
  49. package/dist/mappers.js +169 -0
  50. package/package.json +63 -5
package/README.md CHANGED
@@ -1,3 +1,89 @@
1
- # Temporary Holding Version
1
+ # @jsm-mit/tigi-sharded-package
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The one package of the Tigi network group: it takes the coordinator's id and hides the
4
+ coordinator, the core and the workers — for a consumer the group is one canister. It also
5
+ carries the rider's few driver-canister endpoints (U-14: `getRide`, `cancelRide`,
6
+ `getLicence`), built from `protocol/tigi-driver.did`, so the consumer never sees a driver
7
+ canister's id.
8
+
9
+ Status: the rider's side (night 1, U-42). Version 0.1.0 is the first to publish.
10
+
11
+ ## The rider
12
+
13
+ ```ts
14
+ import { ProfilesActor, RidesActor, TestManagerActor, REQUEST_POLL_MS } from "@jsm-mit/tigi-sharded-package";
15
+
16
+ const profiles = new ProfilesActor(coordinatorId, identity, { host });
17
+ await profiles.setMyProfileAsyncUnsafe("Ala"); // C-2: once, before the first request
18
+
19
+ const rides = new RidesActor(coordinatorId, identity, { host });
20
+ const request = await rides.requestRideAsyncUnsafe({ pickup, destination });
21
+ localStorage.setItem("tigi-request", request.token); // rides.resumeRequest(token) after a reload
22
+
23
+ const snapshot = await request.getAsyncUnsafe(); // every REQUEST_POLL_MS (1 s)
24
+ // snapshot.phase: searching | waitingForDriver ("Zamawiam…", a second or two) | accepted | closed
25
+ // snapshot.offers: a FIXED list (U-42) — by first arrival, new ones at the end, nothing
26
+ // re-sorted; an offer that left keeps its entry with `gone` (rejected | driverNotFree |
27
+ // taken | closed): draw a grey row of the same height there
28
+ await request.rejectOfferAsyncUnsafe(offer.offerId); // ✕ → gone "rejected"; the next nearest driver
29
+ await request.refreshOfferAsyncUnsafe(offer.offerId); // a stale (grey) offer asks again
30
+ await request.chooseOfferAsyncUnsafe(offer.offerId); // ordered (= the ride, accepted at once) | busy | offerExpired
31
+ // | driverNotFree ("Kierowca jest już zajęty") | closed
32
+ await request.giveUpAsyncUnsafe();
33
+ // After "Kierowca anulował kurs" (ride status cancelledByDriver): "Szukaj ponownie" —
34
+ const again = await request.searchAgainAsyncUnsafe(); // a new request, the same pickup and destination
35
+
36
+ const ride = await request.getRideAsyncUnsafe(); // from the driver canister, every RIDE_POLL_MS (2 s)
37
+ await request.cancelRideAsyncUnsafe(); // before inProgress, once
38
+ await request.getLicenceAsyncUnsafe(); // from accepted to the end of the ride
39
+ await request.rateDriverAsyncUnsafe(5); // after completed, once
40
+
41
+ const page = await profiles.getMyRidesAsyncUnsafe(); // the history in the core, 20 a page
42
+ await rides.getPastRideAsyncUnsafe(page.rides[0].rideRef); // its details from the driver canister
43
+ ```
44
+
45
+ What the package does for the network (zgloszenie-i-oferty.md):
46
+
47
+ - the request goes to every worker whose area reaches 3 km around the pickup (ZO-1), found
48
+ with the coordinator's prefix map (kept 30 s; a worker's `NOT_MY_AREA` makes it ask again);
49
+ - 15 s without an offer → 6 km, in the same and in new workers (ZO-8), inside `getAsyncUnsafe`;
50
+ - one choice at a time over all the workers (ZO-14); after an acceptance,
51
+ `closeRequest otherOfferChosen` in the other workers (ZO-15);
52
+ - a stopped canister (an upgrade, IC0508/IC0509) is waited out for about a minute.
53
+
54
+ Errors: `CanisterError` (with `errorKey`; `refusalKeyOf(err)` gives the worker's refusal:
55
+ `ALREADY_OPEN`, `NOT_MY_AREA`, `FULL`, `CLOSED`, `ORDERING`, `DRIVER_NOT_FREE`,
56
+ `NOT_COMPLETED`, `EXPIRED`, `BLOCKED`), `CallRefusedAtInspectionStage`,
57
+ `CriticalCanisterError`.
58
+
59
+ The Test Manager (stage and the test modes): `TestManagerActor.hasSimulatedDriversAsyncUnsafe`,
60
+ `spawnDriversAsyncUnsafe` (12 drivers), `setSpeedUpAsyncUnsafe(request, 10)` before choosing.
61
+ Offers of the simulator have `simulated: true`.
62
+
63
+ ## Scripts
64
+
65
+ ```
66
+ npm run build # tsc (src → dist) and the type-check of the tests
67
+ npm run test-unit # no replica needed
68
+ npm run test-drivers # (a) 5 real driver canisters, driver-bots, route-stub
69
+ npm run test-simulator # (b) the simulator, 20 requests, 20 rides
70
+ npm run test-split # (c) an area split during traffic
71
+ npm run test-smoke # one whole ride with the simulator (run by publish-public)
72
+ npm run publish-public # human-run: publish from master (see below)
73
+ npm run sync-declarations # after a change of a .did (`… protocol` for the protocol and the simulator only)
74
+ ```
75
+
76
+ The end-to-end suites run on the LOCAL replica only (`scripts/run-tests-local.sh`): a fresh
77
+ group, local cycles, the driver and simulator wasms of `../../tigi-driver-rust` (built
78
+ there, never changed). Logs and measurements go to `/tmp/claude-1000/tigi/`
79
+ (`TEST_LOG_DIR`).
80
+
81
+ ## Publishing
82
+
83
+ Human-run only: bump `version` in `package.json` by hand (do not commit it), then
84
+ `npm run publish-public` on `master`. The script refuses unless this repo and
85
+ `../../tigi-driver-rust` are both on a clean `master` equal to `origin/master`, the version is
86
+ new on npm, the declarations match the current builds (core, worker, coordinator, protocol,
87
+ simulator) and the smoke test passes on the LOCAL replica (`dfx start` first). It stamps
88
+ `tigiSharded.commit` and `tigiDriverRust.commit` into `package.json`, publishes, then commits
89
+ "Version bump to <version>" and pushes.