@elaraai/east-claude-plugin 1.0.99 → 1.0.100

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 (32) hide show
  1. package/.build/mcp/server.js +3 -2
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/index.json +12207 -216
  4. package/package.json +1 -1
  5. package/skills/e3/SKILL.md +29 -802
  6. package/skills/e3/reference/browser.md +93 -0
  7. package/skills/e3/reference/cli.md +120 -0
  8. package/skills/e3/reference/from-code.md +48 -0
  9. package/skills/e3/reference/rack.md +139 -0
  10. package/skills/e3/reference/record-indexes.md +326 -0
  11. package/skills/e3/reference/record-migrations.md +63 -0
  12. package/skills/e3/reference/repository.md +25 -0
  13. package/skills/east/SKILL.md +30 -459
  14. package/skills/east/reference/beast2.md +71 -0
  15. package/skills/east/reference/cross-language-and-json-schema.md +87 -0
  16. package/skills/east/reference/queries.md +46 -0
  17. package/skills/east/reference/runners-and-ir.md +148 -0
  18. package/skills/east/reference/trees-and-recursion.md +56 -0
  19. package/skills/east/reference/values-in-typescript.md +62 -0
  20. package/skills/east-py/SKILL.md +28 -1647
  21. package/skills/east-py/reference/beast2.md +108 -0
  22. package/skills/east-py/reference/cli.md +51 -0
  23. package/skills/east-py/reference/columns-and-platform-functions.md +87 -0
  24. package/skills/east-py/reference/control-flow-and-queries.md +147 -0
  25. package/skills/east-py/reference/cross-language.md +70 -0
  26. package/skills/east-py/reference/ir-and-diagnostics.md +150 -0
  27. package/skills/east-py/reference/patterns.md +369 -0
  28. package/skills/east-py/reference/performance.md +70 -0
  29. package/skills/east-py/reference/value-methods.md +306 -0
  30. package/skills/east-py/reference/values-construction-and-json.md +88 -0
  31. package/skills/east-py/reference/writing-east-functions.md +275 -0
  32. package/skills/east-py-datascience/SKILL.md +11 -28
@@ -29,6 +29,10 @@ writing or changing East code:
29
29
  programs, exact and far cheaper, and the signatures omit the runtime rules
30
30
  that make East code correct.
31
31
 
32
+ Tested e3 packages (inputs, tasks, stream tasks and partitions, custom tasks,
33
+ functions, records with their mutations and migrations) are in the index too:
34
+ search with `package: "e3"`.
35
+
32
36
  Nothing is injected for you; the search is the step.
33
37
 
34
38
  ## Quick Start
@@ -68,162 +72,24 @@ What do you need?
68
72
  │ ├─ A named function (RPC) → e3.function(name, fn, config?) — called by name, persists nothing
69
73
  │ ├─ Audited state → e3.record(name, type, { initial?, indexes?, mutations?, migrations? }), declared whole
70
74
  │ │ ├─ Its writes → mutations: (mutation) => ({ name: mutation.reduce | edit | patch })
71
- │ │ ├─ An order to page in → indexes: (index) => ({ name: index.on([...fields]) | index.key(fn) | index.keys(fn) })
75
+ │ │ ├─ An order to page in → indexes: (index) => ({ name: index.on([...fields]) | index.key(fn) | index.keys(fn) }) (reference/record-indexes.md)
72
76
  │ │ ├─ Read by a time window or a 2D window → index.interval | index.area
73
77
  │ │ ├─ Read a block of keys over time tiles, or their totals → index.series | index.summary
74
78
  │ │ └─ Read what rows nest (jobs, a value a day, child rows, trees) a tile at a time, with totals and subtotals
75
79
  │ │ → index.nested({ collections, tile, summary? })
76
- │ ├─ A record's type changes → migrations: (migration) => [migration.value | rows | rekey(name, fn), …], in order
80
+ │ ├─ A record's type changes → migrations: (migration) => [migration.value | rows | rekey(name, fn), …], in order (reference/record-migrations.md)
77
81
  │ ├─ A UI task → ui(name, [inputs], fn) from @elaraai/e3-ui (the e3-ui skill)
78
82
  │ ├─ A function written in python or another node package → East.importFunction(pkg, name, FunctionType) in the body
79
83
  │ └─ Bundle and export → e3.package(name, version, ...items); e3.export(pkg, zipPath)
80
- ├─ Operate it from the shell → the e3 CLI (below): deploy, run, read and write datasets, mutate records, gc
81
- ├─ Delegate local task bodies to a rack → e3 rack enroll + policy; dataflow run --rack, watch --start --rack
84
+ ├─ Operate it from the shell → the e3 CLI (reference/cli.md): deploy, run, read and write datasets, mutate records, gc
85
+ ├─ Delegate local task bodies to a rack → e3 rack enroll + policy; dataflow run --rack, watch --start --rack (reference/rack.md)
82
86
  └─ Drive it from code
83
- ├─ A server, over HTTP → @elaraai/e3-api-client
87
+ ├─ A server, over HTTP → @elaraai/e3-api-client (reference/from-code.md)
84
88
  ├─ A local repository → @elaraai/e3-core
85
89
  ├─ Serve repositories → e3-api-server --repos <dir>, or createServer()
86
- └─ e3 in a browser, no server → @elaraai/e3-web: serveUnits, serveE3, createWebE3 ("Running e3 in a browser")
90
+ └─ e3 in a browser, no server → @elaraai/e3-web: serveUnits, serveE3, createWebE3 (reference/browser.md)
87
91
  ```
88
92
 
89
- ## Rack delegation from a local repository
90
-
91
- **Setup and routing**
92
-
93
- | Signature | Description | Example |
94
- | --- | --- | --- |
95
- | `e3 rack enroll --listen <host:port> [--allow <ip,...>] [--advertise-url <origin>] [--label <label>] [--no-wait]` | Starts the user-wide hub and prints the source origin, the hub's certificate SHA-256, the matching release and a single-use token for the companion's hidden prompts. Waits for a new registration, not activation. Behind an SSH reverse tunnel, listen on the loopback and advertise the relay's origin. | `e3 rack enroll --listen 127.0.0.1:7331 --allow 127.0.0.1 --advertise-url https://relay.example:7401` |
96
- | `e3 rack policy [repo] set <glob> rack\|local [--size <size>] [--timeout <min>] [--allow-host-access]` | First whole-task-name match wins; `*` and `?` are wildcards. Size: serverless, small, medium, large, xlarge. | `e3 rack policy . set 'train_*' rack --size large` |
97
- | `e3 rack policy [repo] enable\|disable\|mode <opt-in\|auto>` | Enable/disable saved opt-in; `mode auto` selects eligible unmatched tasks. Defaults: disabled, opt-in. | `e3 rack policy . enable` |
98
- | `e3 rack policy [repo] defaults [--no-spill] [--claim-timeout <sec>] [--retry-task-failures-locally]` | Defaults: large, 1440-minute timeout, spill on, 30-second claim recheck, no task-failure retry. | `e3 rack policy . defaults --no-spill` |
99
- | `e3 rack policy [repo] show\|unset <glob>\|reset` | Inspect rules, remove an exact pattern, or delete the saved policy. | `e3 rack policy . show` |
100
- | `e3 dataflow run <repo> <ws> --rack\|--no-rack\|--rack-only` | Select rack routing for this run; rack-only disables capacity spill but keeps infrastructure fallback. ❗ Refused for remote URLs. | `e3 dataflow run . dev --rack` |
101
- | `e3 watch <source> <repo> <ws> --start --rack` | Reuses a rack session across watch runs and refreshes capacity; a second Ctrl-C stops the watch at once. ❗ `--rack` and `--rack-only` require `--start`. | `e3 watch src/main.ts . dev --start --rack` |
102
- | `e3 rack status\|list\|remove <id-or-label>\|approve <id-or-label>\|stop` | Inspect fleet, revoke a rack, admit the boot a quarantined rack last reported, or stop the shared hub. Status never starts an absent hub. | `e3 rack status` |
103
- | `e3 rack config [--listen <host:port>] [--allow <ip,...>] [--idle-exit <min>] [--advertise-url <origin>] [--tls\|--no-tls] [--require-approval\|--no-require-approval]` | Configure the shared listener (off by default; HTTPS with the hub's own certificate unless `--no-tls`); every rack and data URL is built on `--advertise-url` when set; zero idle-exit disables automatic shutdown; `--require-approval` quarantines a rack after each reboot until `e3 rack approve` admits it (enrollment admits the first boot). ❗ Plain HTTP only on the loopback or a private address, with `--allow`. | `e3 rack config --listen 10.0.0.5:7331` |
104
-
105
- The local process owns graph planning, repository and cache. After a cache
106
- miss, eligible plain task, map and merge bodies can execute on the rack; input
107
- closures and every output object transfer by hash. The session verifies the
108
- whole output graph before success. Placement never changes task/cache hashes.
109
- Local bodies and fallback share the original cores/memory budget; rack bodies
110
- use remote capacity. Calls, mutations and intake stay local. Stock runner
111
- configurations qualify; commands, custom environments/platforms and unscannable
112
- IR stay local. Host file/environment/network access stays local unless a rule
113
- deliberately grants `--allow-host-access` and its resources exist on the rack.
114
-
115
- The listener serves HTTPS with the hub's own self-signed certificate, made on
116
- first use and kept in `hub-tls.beast2`; a rack pins it by its SHA-256, which
117
- enrollment prints, so TLS runs end to end through any relay or tunnel. The
118
- usual path is an SSH reverse tunnel from the developer machine to a relay the
119
- rack reaches, with the hub on the loopback (`--allow 127.0.0.1`) and the relay's
120
- origin advertised. Removing the certificate file, with the hub stopped, makes a
121
- new one, which every worker must then pin again. `--no-tls` is for a TLS
122
- terminator in front of the hub; the hub refuses plain HTTP on a wildcard or
123
- public address, or without `--allow`. A listener on every address needs
124
- `--advertise-url` to enroll.
125
-
126
- The handoff targets a prepared independent worker VM with the matching verified
127
- `e3-rack` release. Its `configure --allocation <host-provisioned-path>` prompts
128
- for the source origin, the certificate SHA-256 for an HTTPS origin the hub
129
- serves, the worker label and settings; `enroll --allocation <path>` prompts for
130
- the one-time token. Origins, pins and credentials are encrypted together. A
131
- plain-HTTP origin needs `--allow-vpn-http` on both commands and host
132
- authorization for that exact endpoint, and belongs only on a path encrypted end
133
- to end, such as an SSH tunnel, never across a VPN hub that decrypts traffic.
134
- Never put a source address or token in worker command arguments or plaintext
135
- files. The local mint intentionally displays its token; do not log that output.
136
-
137
- Enrollment does not start services or authorize task claims. The local CLI
138
- observes a new registration (optionally filtered by label); compare it with the
139
- worker's result. Before a first heartbeat, status is `enrolled-not-started`.
140
- After managed resume, a ready heartbeat advertises free plus occupied slots;
141
- busy workers stay eligible. Fenced, draining or stopping workers withdraw their
142
- capacity and show `unavailable`. After 45 seconds without a heartbeat, readiness
143
- expires; lease polling cannot prolong it. Source boot approval, when required,
144
- remains an additional gate. This advertisement does not authorize host resource
145
- admission or removal of service/network quarantine.
146
- Resources and mutable whole-GPU assignments belong to the host lifecycle, not
147
- local enrollment flags. The companion accepts up to 32 mutually trusted sources
148
- in one worker. After draining and stopping its services and sockets, use
149
- `configure --allocation <path> --add-source`, confirm the shared trust boundary,
150
- and enter the additional origin privately. It prints the new source UUID for
151
- `enroll --allocation <path> --source <UUID>`; add `--allow-vpn-http` to both for a
152
- plain-HTTP origin. All sources must be enrolled before startup. Each has its own identity,
153
- client, cache and completion journal; actual execution shares one worker-wide
154
- task/GPU limit. Per-source capacity reports are not additive reservations.
155
- A worker is the trust boundary: a shared agent process can access all its
156
- sources' credentials, so separate clients, and a cloud deployment and developer
157
- hubs, need separate worker VMs. The hub keeps no task data; what a worker keeps
158
- between tasks is its own policy, and an agent that keeps nothing works unchanged. Worker-local `source list --allocation <path>`
159
- prints UUIDs/enrollment status; `--show-origins` adds origins only on a terminal.
160
- After drain/stop and source-side revocation, `source remove` or `source reset`
161
- with `--allocation <path> --source <UUID> --acknowledge-revocation` asks for UUID
162
- confirmation. Reset prints a new UUID for fresh enrollment; old pending results
163
- and caches stay in the retired namespace. Other sources and retained data are
164
- preserved, and host endpoint policy must be reconciled before activation. The
165
- flag acknowledges revocation; it does not revoke remotely.
166
-
167
- Worker-local `registry status --allocation <path>` reports only whether encrypted
168
- registry credentials are present; it can run while active and does not test access.
169
- After drain/stop, `registry configure --allocation <path>` privately prompts for
170
- username/token without re-entering settings. `registry clear --allocation <path>`
171
- asks for the installation UUID and removes only the stored access. Both require
172
- the same release, the writer lock and no unresolved enrollment/service transition;
173
- they preserve current identities, rotations, settings, journals and cached data.
174
- Credentials stay in the existing encrypted bundle, with no Docker login file.
175
- A later activation receives them; services remain stopped and the next boot fenced.
176
- Repeating configure with the same values or clear when absent does not write.
177
- Clearing/replacing does not revoke a token remotely or purge cached images.
178
-
179
- The companion's
180
- `reconcile-services` applies a host-provided next allocation and service budgets
181
- after a completed drain, with stopped units, the previous plan hash and exact
182
- operation/boot binding. It retains ciphertext/journals and network quarantine;
183
- it does not move a GPU, start a worker or change its executable release. For a
184
- compatible release change, invoke the target verified executable's `switch-release`
185
- with the same drain/plan bindings and unchanged resource budgets at the next
186
- allocation generation. It checks both managed-state contracts, updates only the
187
- runtime version in the current encrypted configuration, and preserves identities
188
- and journals through interruption or downgrade. Both four-file releases must stay
189
- available; a downgrade is a new operation, never a saved-state restore. Services
190
- stay stopped and quarantined. If the selected release never resumed, the exact
191
- recorded previous executable's `recover-release` binds the completed release
192
- receipt, current plan and new operation at another generation increase. It
193
- requires the original drain or a valid fenced journal with no operation at the
194
- failed generation, verifies both releases' recorded hashes, and preserves current
195
- credentials and journals. A prior resume attempt, even across reboot, refuses
196
- recovery. General journal repair remains unfinished. Named host management, source aliases, network
197
- activation, incompatible-state migrations and hardware acceptance remain
198
- companion cloud #253 work. This and durable completion retry are implemented in
199
- companion PR #254, separately from the original main protocol pin.
200
-
201
- Policy is `<repo>/rack/policy.beast2`; hub state is `~/.e3/rack` (or
202
- `E3_RACK_HOME`). A hub `dataflow run` starts exits after 15 idle minutes, and a
203
- run waits up to 10 seconds for an enrolled rack to report healthy (with none
204
- enrolled, or a policy that selects no task for a rack, it starts at once): run
205
- `e3 rack hub` as a service, or set `--idle-exit 0`, for a hub racks can always
206
- reach. A data URL lasts 15 minutes, which a transfer may use whole; an object is
207
- at most 5 GiB. The control schema currently requires protocol 2 exactly.
208
- Agents must report bundled e3 at least the project's release. Infrastructure
209
- failure falls back locally with a separate execution attempt, as does an
210
- attempt the rack stopped on its own; the run's own cancellation and the task's
211
- timeout never do. One cancelled subscriber does not stop work shared by other
212
- sessions of the same canonical repository and e3 release.
213
-
214
- **Programmatic attachment** (`@elaraai/e3-rack`)
215
-
216
- | Signature | Description | Example |
217
- | --- | --- | --- |
218
- | `openRackRunner({ repoPath, workspace, storage, label, budget?, settings?, policy?, rackOnly? })` | Opens a runner/session; preserve the caller's existing budget and process settings, use `rackSlots` to extend orchestrator width, and close in `finally`. | `const rack = await openRackRunner({ repoPath, workspace: 'dev', storage, label: 'run', budget });` |
219
- | `createDataflowRunnerFactory(options?)` | Pass to `createServer({ dataflowRunner })`; one session per API dataflow, using the server's shared budget. Explicit server opt-in overrides policy.enabled; rules still apply. | `const server = await createServer({ reposDir: './repos', dataflowRunner: createDataflowRunnerFactory() });` |
220
-
221
- The API server's optional rack package is needed only for
222
- `e3-api-server --repos ./repos --rack`. Portable handlers receive a runner
223
- factory and do not import hub code. Custom environments, remote function
224
- delegation, automatic reconnect after hub restart and embedded UI integration
225
- are deferred.
226
-
227
93
  ## Authoring a package
228
94
 
229
95
  ### Inputs — `e3.input(name, type, source?)`
@@ -604,665 +470,12 @@ encoded size, so wide rows get segments of a few rows and a one-row edit stays
604
470
  cheap. A view reads every field of the rows it shows, so keep a bulky payload it
605
471
  does not display in a second record keyed the same way.
606
472
 
607
- #### Secondary indexes — `index.on([...fields])`, `index.key(fn)`, `index.keys(fn)`
608
-
609
- A second collection over a Dict record, in another sort order, maintained in the
610
- same commit, so a view by an attribute is a page rather than a scan.
611
- `index.on([...])` names row fields in index order: one field uses its value as
612
- the key, several use a Struct in that order, and a Set field gives an entry per
613
- element. It also carries field metadata for `Data.bindPaged(record, { indexes })`
614
- and `Slice.bindRecord` (see **e3-ui**). `index.key(fn)` gives one computed entry
615
- per row; `index.keys(fn)` returns a Set, one entry per element (a row naming five
616
- resources appears five times, an empty set not at all); the `value` option of
617
- each is a projection a view renders without touching the record. The functions
618
- are pure and synchronous, since an index maintained commit by commit must equal
619
- its rebuild to the byte. Its name — its key in `indexes` — is an identifier,
620
- never `primary` (the record's own order). Read through one with `index=<name>` on a page or key search; `e3
621
- reindex` rebuilds. A deploy builds an index the package declares and the state
622
- lacks, drops one it no longer declares, and runs nothing for the rest; a build
623
- is a split task over the record.
624
-
625
- ```typescript
626
- const plans = e3.record('plans', PlansType, {
627
- initial: new Map(),
628
- indexes: (index) => ({
629
- by_due: index.on(['due']),
630
- by_owner_due: index.on(['owner', 'due']),
631
- by_owner: index.key(East.function([StringType, PlanType], StringType, ($, _id, plan) => plan.owner), {
632
- value: East.function([StringType, PlanType], StringType, ($, _id, plan) => plan.title),
633
- }),
634
- by_resource: index.keys(East.function([StringType, PlanType], SetType(StringType), ($, _id, plan) => plan.resources)),
635
- }),
636
- mutations: (mutation) => ({ /* add_plan, reschedule, patch — above */ }),
637
- });
638
- const pkg = e3.package('planning', '1.0.0', plans); // the record whole: its indexes and mutations with it
639
- ```
640
-
641
- #### Interval and area indexes — `index.interval`, `index.area`
642
-
643
- These indexes answer more than an order — as do the series and summary indexes
644
- below — each with a builder method of its own whose keys the SDK generates.
645
- Underneath each is an ordinary index — the same build,
646
- mutation, storage, paging and `e3 reindex` — and the record Slice reads a
647
- window through either (see **e3-ui**). Their generated keys are query
648
- machinery: edits and sessions always target the record's primary key.
649
-
650
- A generated key is a struct whose own fields are e3's: `on` holds the
651
- declaration's leading fields, by their names, at their key types (a Set field's
652
- element type) — a struct with no fields when it lists none — and the kind's own
653
- parts sit beside it. So no name is reserved: a row may name a field anything,
654
- `area`, `tile` and `__area` among them, and an index may be led by it.
655
-
656
- | Index | Key | e3's parts |
657
- |---|---|---|
658
- | interval | `{ on, node, at }` | the tree node an entry is filed at; the instant it is ordered by, at the `from` field's type |
659
- | area | `{ on, area }` | the cell's Morton code times 32 plus its level; −1 for a row not yet placed |
660
- | series | `{ on, key, level, tile }` | the value of the field `key` names; the level an event is filed at, and the start of that level's tile (#1433) |
661
- | summary | `{ on, key, tile }` | the value of the field `key` names; the tile's start |
662
-
663
- A definition's `on` is the leading fields alone; its kind's options say the
664
- rest (`events.indexes.by_time.interval`, `racks.indexes.racks_by_area.area`,
665
- `jobs.indexes.jobs_by_press_week.series`).
666
-
667
- **`index.interval({ on?, from, to })`** keeps events visible while they
668
- overlap a selected time window. `from` and `to` are the row's DateTime or
669
- Option<DateTime> fields; optional `on` fields are exact leading choices:
670
-
671
- ```typescript
672
- const events = e3.record('events', EventsType, {
673
- initial: new Map(),
674
- indexes: (index) => ({
675
- by_time: index.interval({ from: 'start', to: 'end' }),
676
- by_status_time: index.interval({ on: ['status'], from: 'start', to: 'end' }),
677
- }),
678
- });
679
- ```
473
+ A record's indexes (`index.on` / `key` / `keys`, `interval`, `area`,
474
+ `series`, `summary`, `nested`) are in
475
+ [reference/record-indexes.md](reference/record-indexes.md), and its migrations
476
+ in [reference/record-migrations.md](reference/record-migrations.md).
680
477
 
681
- Its key is `{ on, node, at }`. It stores at most three entries per event per
682
- leading-field combination, independent of duration. The record Slice adapter resolves a half-open
683
- `[from, to)` window with at most 55 disjoint bounded queries per exact prefix;
684
- each matching original record occurs once, including events that started
685
- earlier or span the whole window. It never scans the record or guesses a
686
- maximum duration. An event ending at `from` is outside; an instant at `from`
687
- is inside and one at `to` is outside. A missing or non-positive end is an
688
- instant. A missing start remains selectable as Unset/backlog.
689
-
690
- Use `on: ['start']` only when the intended query is **starts within**, since it
691
- cannot preserve carry-in events. When both declarations are available, a Slice
692
- range on the start field uses the interval declaration. The generated interval
693
- keys are query machinery; record edits and sessions always target the original
694
- primary key. Calendar's `Calendar.events(binding, { slice, entries, … })`
695
- requires a matching interval declaration and the primary `entries` binding to
696
- confirm saves even after an edit leaves the selected window.
697
-
698
- **`index.area({ on?, x, y, width?, height?, at?, cell })`** reads the rows
699
- whose box meets a 2D window — what a floor plan's viewport shows — the interval
700
- index's twin:
701
-
702
- ```typescript
703
- // RacksType: Dict<String, { hall: String, x: Option<Float>, y: Option<Float>, w: Float, h: Float }>
704
- const racks = e3.record('racks', RacksType, {
705
- initial: new Map(),
706
- indexes: (index) => ({
707
- racks_by_area: index.area({ x: 'x', y: 'y', width: 'w', height: 'h', at: 'centre', cell: 0.01 }),
708
- racks_by_hall_area: index.area({ on: ['hall'], x: 'x', y: 'y', width: 'w', height: 'h', at: 'centre', cell: 0.01 }),
709
- }),
710
- });
711
- ```
712
-
713
- | Option | The box's |
714
- |---|---|
715
- | `x`, `y` | place: two Float fields, or two Option<Float> fields whose `none` is a row not yet placed |
716
- | `width`, `height` | size: two Float fields, or neither for a point |
717
- | `at` | `'corner'`, the default — `x`, `y` is the box's minimum corner, as a zone's is — or `'centre'`, as an item's is |
718
- | `cell` | finest cell: its side in world units, about the smallest thing drawn — 0.01 for a floor in metres, 1 for one in millimetres. It is rounded down to a power of two, so the keys' arithmetic is exact on every runtime, and has no default: a wrong one costs a silent tenfold read |
719
- | `on` | exact leading fields, as the interval index's; a Set field fans out |
720
-
721
- Each option takes only the row's fields of its type, so a wrong one does not
722
- compile, and the definition checks them again, naming the option, the field and
723
- its type. The domain is the square ±`cell`·2²⁷ world units around zero
724
- (±1,048 km at a 0.01 cell, which rounds to 2⁻⁷), in 29 levels. Each row is
725
- filed once, under the deepest level whose cell is at least twice its box's
726
- larger side, in the cell holding its box's centre: the key
727
- `{ on, area: Integer }`. A row not yet placed files under `area` −1, which the
728
- record Slice reads as the unplaced clause; one outside the domain, not finite,
729
- or larger than half of it files under the root, which every window reads. The index **carries its rows**: each
730
- entry's projection is the whole row, so a window reads the index alone and no
731
- record segment, and it takes no `value`. The record Slice reads a viewport,
732
- grown by an eighth of its larger side on each side, as at most 266 disjoint
733
- searches per exact prefix, sent in one request, which together hold every row
734
- whose box meets it, each once — beside rows of the cells searched that it
735
- misses, which the reader draws or not.
736
-
737
- #### Series and summary indexes — `index.series`, `index.summary`
738
-
739
- What a planning board reads: the events on a block of keys — a Plan's
740
- resources — over a span of time, and, zoomed out past what a screen can draw,
741
- how busy each key is. Both file a row's event by the key it is on and by time
742
- tiles — `day`, `week` (ISO, from Monday), `month`, `quarter` or `year`, in UTC,
743
- half-open — the key before the time, so a key's entries over any span are
744
- contiguous: a series index's `{ on, key, level, tile }`, a summary index's
745
- `{ on, key, tile }`.
746
-
747
- ```typescript
748
- // JobsType: Dict<String, { press: String, start: Option<DateTime>, end: Option<DateTime>, … }>
749
- const jobs = e3.record('jobs', JobsType, {
750
- initial: new Map(),
751
- indexes: (index) => ({
752
- jobs_by_press_week: index.series({ key: 'press', from: 'start', to: 'end', tile: 'week' }),
753
- jobs_by_press_month: index.summary({ key: 'press', from: 'start', to: 'end', tile: 'month' }),
754
- }),
755
- });
756
- ```
757
-
758
- | Option | |
759
- |---|---|
760
- | `key` | the field naming what an event is on: any field but a Set |
761
- | `from`, `to` | the event's start and end: DateTime or Option<DateTime> fields. A row with no start is filed nowhere; no end, or one at or before the start, is an instant |
762
- | `tile` | a series index's finest level, and a summary index's tile: `day`, `week`, `month`, `quarter` or `year` |
763
- | `on` | exact leading fields, before the key; a Set field fans out |
764
-
765
- **A series index** is an ordinary index whose keys the SDK generates, and it
766
- **carries its rows**, as the area index does. It files each event **once**, at
767
- the finest level from its `tile` up to the year whose shortest tile holds the
768
- event's length — a day, a week, 28 days, 90 days, 365 days — under that level's
769
- tile holding its start; an instant at `tile`; past 365 days, under each year it
770
- touches. An event filed at a level ends within the tile after the one holding
771
- its start, so a reader reads a block of keys over any span from the index alone
772
- as one range a key a level — that level's tiles from two before the span to one
773
- after it — in one request, whatever the span's width. **A summary index** holds,
774
- under each key and tile, `{ count, ms }`: how many rows touch the tile, and the
775
- milliseconds of it they cover — a row's shares
776
- add up to its length, and an instant's is none. Each entry stands for every row
777
- of its key and names none, so its window's `key` is Null, a read of it joins
778
- nothing, and a read that needs its rows — a joined read, a placement
779
- (`datasetPlace`) or a membership read (`datasetWithin`) — is refused, naming the
780
- index; the record's describe says it is a summary. A write
781
- changes its totals by what its rows took away and gave — its program reads the
782
- record, never the summary — and the apply adds that to each total, dropping one
783
- whose count reaches zero; the totals are Integers, so a maintained summary is the
784
- one `e3 reindex` sums, byte for byte, and a build split into pieces adds the
785
- pieces' totals of a key. A change that would leave a total no rebuild sums — a
786
- count below zero, or time with no row — fails the write, naming the total and
787
- `e3 reindex`, which rebuilds it; a total past the largest Integer fails the
788
- write or the build, naming a finer tile.
789
-
790
- A series index files an event past a year under each year it touches, as many
791
- as 4,096: one touching more is refused where it is written, naming it and its
792
- span. A summary splits an event over its tiles, as many as 4,096 — eleven years
793
- of days — and one touching more is refused the same way, naming the tile:
794
- declare a coarser tile. Each option takes only the row's fields of its type, as
795
- the area index's do, and the definition checks them again; a `value` is
796
- refused, and so is an `on` field that is the key, the start or the end: the key
797
- follows the leading fields, and the tiles are cut by the start and the end.
798
-
799
- #### Nested series indexes — `index.nested`
800
-
801
- What a planning board reads when a record's rows nest what it draws: a
802
- machine's jobs and its load a day at a time, a hall's members, an assembly's
803
- parts to any depth. One declaration a record lists every collection its rows
804
- nest, each field with a builder saying what it holds. e3 files each item apart
805
- from its row — once, by its collection, its row, its node and its time — keeps
806
- each node's totals a summary tile at a time, and each parent's subtotals at
807
- every level; and the record's other indexes carry the rows without those
808
- collections, so a page of rows reads none of them and a window of items reads
809
- no row.
810
-
811
- ```typescript
812
- // MachinesType: Dict<String, { name, site, status, jobs: Dict<String, Job>, load: Dict<DateTime, Float> }>
813
- const machines = e3.record('machines', MachinesType, {
814
- initial: new Map(),
815
- indexes: (index) => ({
816
- machines_in_time: index.nested({
817
- collections: {
818
- jobs: index.nested.items({ from: 'start', to: 'end' }), // things people drag: by id, their times fields
819
- load: index.nested.values(), // a value per instant: keyed by the instant
820
- },
821
- tile: 'week',
822
- summary: 'month',
823
- }),
824
- machines_by_site: index.on(['site']), // pages each machine without its jobs and load
825
- }),
826
- });
827
- // Each member's load, and each hall's mean of its members', at every level from the day up.
828
- const halls = e3.record('halls', HallsType, {
829
- indexes: (index) => ({
830
- halls_in_time: index.nested({
831
- collections: { members: index.nested.rows({ load: index.nested.values({ rollup: 'mean' }) }) },
832
- tile: 'day',
833
- summary: 'month',
834
- }),
835
- }),
836
- });
837
- // Parts to any depth, each part's jobs filed under every part above it too.
838
- const assemblies = e3.record('assemblies', AssembliesType, {
839
- indexes: (index) => ({
840
- assemblies_in_time: index.nested({
841
- collections: {
842
- parts: index.nested.rows({
843
- jobs: index.nested.items({ from: 'start', to: 'end' }, { rollup: true }),
844
- parts: index.nested.recursive(),
845
- }),
846
- },
847
- tile: 'week',
848
- summary: 'month',
849
- }),
850
- }),
851
- });
852
- ```
853
-
854
- | Builder (`index.nested.…`) | A field holding |
855
- |---|---|
856
- | `items({ from, to })`, `items({ at })` | `Dict<String, Struct>`: things people drag, by id; their times are DateTime or Option<DateTime> fields — no start files an item nowhere, no end (or one at or before its start) makes it an instant. `{ rollup: true }` files each under every ancestor too |
857
- | `values({ rollup? })` | `Dict<DateTime, V>`: a value per instant. `rollup` keeps every parent's subtotals |
858
- | `rows({ … })` | `Dict<String, Struct>`: child rows, their own collections declared the same way |
859
- | `recursive()` | `Dict<String, Self>`: more rows like the one listing it, to any depth |
860
-
861
- TypeScript types `collections` field by field from the record's type alone: a
862
- misnamed time, or a builder on the wrong kind of field, is an error where it is
863
- written, and its message says what fits. The definition checks the same again,
864
- in words, for a declaration TypeScript could not see. A record has one nested
865
- series index, which takes no `on` and no `value`.
866
-
867
- **What it files.** Every entry is keyed `{ collection, row, path, run, level,
868
- tile, item }` (e3-types' `NestedEntryKeyType`): the collection's place, the
869
- field names from the row down (`members` then `load`); the row's key; the Dict
870
- keys from the row down to the node (`[]` for the row, `m-3` for a member); the
871
- run; the level and tile; and the item. A place and a path are held as a key
872
- holds a list, folded from the last: `.step (key="members", rest=.step
873
- (key="load", rest=.end))`. Each run of a node is one contiguous range a level:
874
-
875
- | Run | Holds |
876
- |---|---|
877
- | `items` | each item once, as a series index files an event — at the level its length fits, past a year under each year — carrying it (`.item .jobs (…)`); a value, and an `{ at }` item, at the declared tile alone |
878
- | `totals` | where `summary` is declared, each node's `{ count, ms, values }` a summary tile at a time; for a Float or Integer collection, `values` is the sum, the least, the greatest and the last there, taken in key order |
879
- | `subtotals(rollup)` | for `values({ rollup })`, every parent's subtotal by each rollup at each level from `tile` to the year, where a descendant's value touches the tile: a node holding values folds its own, a parent aggregates its children's, in key order |
880
- | `subtree`, `subtreeTotals` | for `items(…, { rollup: true })`, each item under every ancestor too, `.under (path, id)`, and each ancestor's totals of them |
881
-
882
- A rollup is `'sum'`, `'mean'` (a mean of means up the tree), `'min'`, `'max'`,
883
- `'count'` (the leaf rows beneath that hold a value), a fold and an aggregate
884
- named apart (`{ fold: 'last', aggregate: 'sum' }`, a balance), or several.
885
-
886
- **Reading.** A reader searches the index's leading fields — `[collection, row,
887
- path, run, level, tile]`, each as East prints it — as a range a row a level: a
888
- block of fifty machines' jobs over three weeks is fifty times four ranges in one
889
- `datasetFindKeys` request, and one `datasetGetRuns` read of the entries they
890
- select, each job carried whole; a parent's week subtotals are one range; a
891
- part's subtree is one range a level.
892
-
893
- **The lean rows.** Beside a nested series index, every other index of the
894
- record that carries nothing or the row carries the row without the listed
895
- collections — each listed collection empty, child rows kept with theirs empty —
896
- so a page of rows read without a join reads no nested item and no segment of
897
- the record's own. An index with a `value` of its own carries its own. A
898
- binding of the record's indexes lists the nested index by name beside any that
899
- carry the lean rows — `Data.bindPaged(machines, { indexes: ['machines_by_site',
900
- 'machines_in_time'] })` (see **e3-ui**).
901
-
902
- **Its span.** Beside every nested series index e3 keeps its span, an index of
903
- the record's named `<index>_span` (e3-types' `nestedSpanName`), built with it
904
- and never declared: under each collection's place and each month its items or
905
- values touch (`NestedSpanKeyType`, `{ collection, tile }`), how many of them
906
- touch it and the milliseconds of it its items cover, summed across the rows as a
907
- summary index's totals are, and a month let go once nothing touches it. A
908
- collection's first and last month held are its span across the record — what a
909
- Plan's horizon covers for the series reading it — and its months' counts are
910
- how much it holds in each, which the horizon's strip draws as its bars (see
911
- **e3-ui**). Reading it is one search a collection, an exact match on its
912
- place, and one read of the first and last entry of each. An index the record
913
- declares under that name is refused.
914
-
915
- **Writes.** A row a write updates by a patch is maintained by the patch: e3
916
- walks it along the declaration — each collection's Dict patch, and each child
917
- rows' — and compares the entries of only the items it names, with the totals of
918
- the summary tiles they touch and the subtotals of the tiles they touch at each
919
- level. A replace on the way, which a recursive type's patch always is, and an
920
- inserted or deleted row are compared whole. Both ways give the same delta, and a maintained
921
- index is the one `e3 reindex` rebuilds, byte for byte.
922
-
923
- #### Migrations — how a record's type changes
924
-
925
- | Form | Function | Runs as |
926
- |---|---|---|
927
- | `migration.value(name, fn)` | `(Old) => New`, over any record | one unit; its runner opens the state lazily |
928
- | `migration.rows(name, fn)` | a Dict's rows, `(K, V1) => V2` with the keys kept, or an Array's elements, `(T1) => T2` | a task split over the state: a piece at a time, in parallel, each piece cached |
929
- | `migration.rekey(name, fn)` | a Dict's entries, `(K1, V1) => { key: K2, value: V2 }`, or a Set's elements, `(T1) => T2` | the same split task, its pieces merged by key: two Dict rows landing on one key fail the deploy, naming it; two Set elements are one |
930
-
931
- A record's steps are one chain: the list `migrations` returns, in order, each
932
- step taking the record as the step before it leaves it, and the last leaving it
933
- as its declared type — each checked where the record is declared.
934
- A step's name is an identifier, unique on the record, and a workspace records the
935
- steps it has applied by name — so moving a step's code, or re-exporting it with a
936
- newer e3, does not run it again, and an edit to an applied step's body is not
937
- detected. The functions are pure, synchronous East.
938
-
939
- ```typescript
940
- const RowV1Type = StructType({ title: StringType });
941
- const RowV2Type = StructType({ title: StringType, owner: StringType });
942
- const plans = e3.record('plans', DictType(StringType, RowV2Type), {
943
- initial: new Map(),
944
- migrations: (migration) => [
945
- migration.rows('add_owner', East.function([StringType, RowV1Type], RowV2Type, ($, _id, row) => ({ title: row.title, owner: 'unassigned' }))),
946
- // The next version adds its step here, after this one.
947
- ],
948
- });
949
- const pkg = e3.package('planning', '2.0.0', plans);
950
- ```
951
-
952
- What a deploy does with each record, decided before it writes anything:
953
-
954
- | The workspace holds | Against the package's chain | The deploy |
955
- |---|---|---|
956
- | no state | — | mints `$init` from the initial value, the whole chain counted applied; declared with no initial value, leaves it unassigned (`unassigned`) for `e3 seed` |
957
- | state | every step applied, the type unchanged | keeps it, with a `$deploy` commit when the package changed |
958
- | state | a proper prefix applied | runs the rest, a `$migrate:<name>` commit each |
959
- | state | every step applied, but the type changed | refused: a type change needs a migration, or `--schema reset` |
960
- | state | applied steps the chain does not start with | refused, naming the steps applied and those declared |
961
- | a record the package no longer declares | — | refused unless `--allow-drop-records` |
962
-
963
- `--schema <policy>` on `e3 workspace deploy` and `e3 watch`: `migrate` (the
964
- default), `fail` (run no migration; refuse) or `reset` (reset the record to its
965
- initial value, with a `$reset` commit (`reset`); one declared with no initial
966
- value goes back to unassigned (`unassign`), for `e3 seed` again). `--plan` prints what the deploy would do
967
- to each record, index and input and writes nothing — from a zip or a source it
968
- imports nothing, and a server plans only a package it holds. The steps run
969
- before the deploy writes: a failed step leaves the workspace as it was, and a
970
- deploy run again is served the steps that finished from the cache.
971
-
972
- What a deploy does with each input — a dataset an `e3.input` declares, which
973
- people set:
974
-
975
- | The input now | Its type | The deploy |
976
- |---|---|---|
977
- | holds the value the deployed package gave it, or is new | — | the new package's value (`package`) |
978
- | someone set it | — | the new package's value under `--inputs reset`, the default, and says it reset it (`reset`) |
979
- | someone set it | the new package's | kept, under `--inputs keep-edited` (`keep`) |
980
- | someone set it | changed | the new package's value, and says why (`reset`) |
981
- | the deployed package took it from a file, and it holds a value | — | the new package's value under either policy, since a value set since cannot be told from the file's, and says so (`reset`) |
982
- | the new package takes it from a file | — | its file, as every deploy does (`file`); a deploy that reads no file, a server's, leaves it unset for its client to send |
983
- | the new package no longer declares it | — | gone, with its value (`drop`) |
984
-
985
- ## The e3 CLI
986
-
987
- Every `<repo>` is a local path or a server URL, `http(s)://<host>/repos/<name>`;
988
- where `[repo]` is optional it defaults to `$E3_REPO`, then `.`. Dataset paths are
989
- flat, `<ws>.<name>` — an input or a task output, with "did you mean" suggestions;
990
- a task is `<ws>.<task>` and a mutation `<record>.<mutation>`.
991
-
992
- | Command | Does |
993
- |---|---|
994
- | **Repositories** | |
995
- | `e3 repo create [repo] [--exist-ok]` | Create one (`--exist-ok`: succeed if it exists). |
996
- | `e3 repo status [repo]` · `e3 repo remove [repo] [-r]` | Show objects, packages, workspaces · remove (`-r`: its workspaces first). |
997
- | `e3 repo gc [repo] [--dry-run] [--keep-runs <n>] [--keep-days <d>] [--min-age <ms>]` | Drop old run history, then what nothing names (below). |
998
- | `e3 repo list <server>` | The repositories a server holds. |
999
- | **Packages** | |
1000
- | `e3 package import [repo] <zip>` · `export [repo] <pkg[@ver]> <zip>` | Import · export (`--quiet`: errors only). |
1001
- | `e3 package list [repo]` · `remove [repo] <pkg[@ver]>` | |
1002
- | **Workspaces** | |
1003
- | `e3 workspace create [repo] <ws>` · `list [repo]` · `status [repo] <ws>` · `remove [repo] <ws>` | `status` shows tasks, datasets and locks. |
1004
- | `e3 workspace copy [repo] <from> <to>` | Make `<to>` what `<from>` is now — its package and every input, record and task output, so nothing runs again — made, or replaced whole with its runs. It writes refs only, so its cost follows the number of datasets, never their size; a write to either afterwards leaves the other as it was. Refused while a dataflow runs in `<to>`. |
1005
- | `e3 workspace deploy [repo] <ws> <pkg[@ver]>` | Deploy an imported package. |
1006
- | `… --from-zip <zip>` · `… --from-source <src.ts> [--functions <manifest…>]` | Import the zip (or bundle the source) and deploy, creating the workspace. |
1007
- | `… [--schema <policy>] [--inputs <policy>] [--allow-drop-records] [--plan] [--skip-file-sources] [-j <n>] [--memory <size>] [--quiet]` | A record's policy, an input's, and `file` sources; says how far it has got (below), `--quiet` aside. `-j`: the `file` sources taken in at once, and the runner processes their intake units, the migrations and the index builds run on, and with `--from-source` the workspace packages exporting their functions at once; `--memory`: what those may reserve (local). |
1008
- | `e3 workspace export [repo] <ws> <zip> [--name <n>] [--version <v>]` | The workspace's state as a package. |
1009
- | **Datasets** | |
1010
- | `e3 dataset get [repo] <ws.name> [-f east\|json\|beast2]` | Print a value. |
1011
- | `e3 dataset set [repo] <ws.name> <file> [--type <spec> \| --type-file <path>]` | Write from `.east`, `.beast2`, `.json` or `.csv` (JSON and CSV need the type). |
1012
- | `e3 dataset set [repo] <ws.name> --from-file <path.beast2> [-j <n>] [--memory <size>]` | Take a beast2 file in as the value, as a deploy takes a `file` source in, saying how far it has got; `-j`, `--memory`: the budget its intake units run under (local). |
1013
- | `e3 dataset list [repo] <ws> [-l]` · `status [repo] <ws.name>` · `find [repo] <ws> <pattern>` | Paths (`-l`: kind, type, status, size) · one dataset · by substring or glob. |
1014
- | **Running** | |
1015
- | `e3 dataflow run [repo] <ws> [--filter <task>] [--force \| --force-task <task>…] [-j <n>] [--memory <size>] [-v]` | Run what is stale, then print the outputs' paths. `--filter`: one task, by its exact name, and the tasks it depends on. `--force`: re-run every task the run runs (under `--filter`, its task); `--force-task`, repeated for each: re-run the tasks it names, whose dependents re-run when an output changes. A task the graph lacks, or one `--filter` leaves out, refuses the run. A task whose input nothing has set — an input never set, or a record declared with no initial value and not yet seeded — is left waiting, with its dependents (`[WAIT]`, `Waiting:`), and the run completes without them; they run once it is set. |
1016
- | `e3 task list [repo] <ws>` | Tasks with the status of each one's latest run. |
1017
- | `e3 task logs [repo] <ws.task> [-n <lines>] [--all] [--follow] [--execution <task>/<inputs>/<id>]` | The last 200 lines by default, of the latest attempt over the task's current inputs, or its latest run; `--follow` stays on that execution; `--execution`: one unit's log, as a split task's log names it (local). |
1018
- | `e3 run <repo> <pkg[@ver].task> [inputs.beast2…] -o <out> [--force] [-v] [-j <n>] [--memory <size>]` | Run one task ad hoc. |
1019
- | `e3 call <repo> <pkg[@ver].fn> [args…] [-o <out.beast2>] [-j <n>] [--memory <size>] [-v]` · `e3 call <repo> -w <ws> <fn> [args…]` | Call a function; each argument is an `.east` literal or a `.beast2`/`.json`/`.east` file, and with `-w` one written `@<keypath>` (`@.inputs.sales`) is that dataset of the workspace, pinned at its hash when the call starts. |
1020
- | **Records** (`-w <ws>` required) | |
1021
- | `e3 mutate <repo> <record.mutation> [args…] -w <ws> [-j <n>] [--memory <size>] [-v]` | Apply a mutation. |
1022
- | `e3 seed <repo> <record> <file.beast2> -w <ws> [-j <n>] [--memory <size>]` | Commit a record's first state from a beast2 file, as its `$init`: for a record declared with no initial value, unassigned until then (local). The file is taken in as a `file` source is, never read whole; a record that holds a state is refused. |
1023
- | `e3 history <repo> <record> -w <ws> [--limit <n>] [--from <hash>] [--delta]` | Commits, newest first (`--delta`: what each changed, per target — a summary's totals added to as `±n`; local). |
1024
- | `e3 reindex <repo> <record> -w <ws> [--index <name>] [-j <n>] [--memory <size>]` · `e3 compact <repo> <record> -w <ws>` | Rebuild indexes (local) · collapse the history to a `$compact` root, the state kept. |
1025
- | **Development** | |
1026
- | `e3 watch <src.ts> <repo> <ws> [--start] [--schema <p>] [--inputs <p>] [--abort-on-change] [--functions <manifest…>] [-j <n>] [--memory <size>]` | Redeploy on each change (and run, with `--start`). |
1027
- | `e3 convert [input] [--from <f>] [--to <f>] [--type <spec>] [-o <out>]` | Convert between `.east`, `.json` and `.beast2`. |
1028
- | `e3 completion install [--shell <s>]` · `uninstall` · `bash` \| `zsh` \| `fish` | Shell completion. |
1029
- | **Servers** | |
1030
- | `e3 auth login <server> [--no-browser]` · `logout <server>` · `status` · `token <server>` · `whoami [server]` | OAuth2 device flow; credentials per server (`token` prints one for curl). |
1031
-
1032
- **The budget.** `-j`/`--jobs <n>` is the cores — runner processes in flight, a
1033
- task or a unit each — and `--memory <size>` (`8G`, `512M`) what they may reserve
1034
- between them. The defaults are `E3_JOBS` and `E3_MEMORY`, else what e3 may use:
1035
- its CPU affinity capped by a cgroup quota, and the cgroup's `memory.max` or
1036
- physical memory, less a reserve. A unit of a split task reserves the largest
1037
- peak a unit of its stage has reached in the run, so a stage runs its first unit
1038
- alone and then fans out; on Linux and macOS a guard stops the newest unit when
1039
- the runners together pass the budget, and runs it again once it fits. A deploy
1040
- takes its `file` sources in `-j` at a time, their pieces' intake units running
1041
- under the same budget. A source deploy, or a `watch`, exports the workspace
1042
- packages its imported functions come from `-j` at a time, a process each, on
1043
- this machine; against a server, as many at once as this machine has CPUs. The
1044
- commands that run East — `workspace deploy`,
1045
- `dataset set --from-file`, `dataflow run`, `run`, `call`, `mutate`, `seed`,
1046
- `reindex` and `watch` — take the flags for a local repository; against a server the CLI
1047
- refuses them, since the server runs the work under its own budget
1048
- (`e3-api-server -j`, `--memory`).
1049
-
1050
- **A deploy says how far it has got**, on stderr. Each `file` source prints a
1051
- line once it is in: its size, time and rate, and how it was taken in
1052
- (`unchanged, already in the store`, `taken in by east-c`, or `carried` for a
1053
- value that is not a collection), with why the first time a runner fell back to
1054
- another. A terminal also keeps a live line for the files in flight, with their
1055
- pieces, the rate and the time left across them. A source deploy prints a line
1056
- for each workspace package whose functions it links: `exported <n> function(s)
1057
- of <pkg> (east-py export-functions)`, or `reused <n> function(s) of <pkg>,
1058
- unchanged since its last export` when the export cache held them. Against a
1059
- server, the deploy line
1060
- says what the job is doing, such as migrating a record or building an index;
1061
- the deliveries then upload a few at a time, each printing a line once it is in,
1062
- and the live line says what the server's commit is doing with each in flight.
1063
- While a deploy runs, its lock carries the same progress for `e3-ui` or any
1064
- client to read (`workspaceLockStatus`). A workspace deployed for the first time
1065
- has no status until its deploy ends, so the lock is the only place to see it.
1066
-
1067
- **`-v`** passes `-v` to the runners, which print to the task's logs, identically
1068
- on every runtime, how each input was read — opened lazily, and what reading it
1069
- came to, or decoded whole, and the resident memory that added — and a timing
1070
- and peak-memory block. It never changes hashes or caching (add `--force` to see
1071
- it for a cached task), and works against a server.
1072
- **Where a task's time goes.** `EAST_PROFILE=1` in the environment of a local
1073
- `e3 dataflow run` (or `run`, `call`, `mutate`) has the east-c and east-py
1074
- runners profile each unit — the runners inherit e3's environment — and the
1075
- task's log (`e3 task logs`) then ends with every East function and platform
1076
- function it called, by self time, with its calls and where it was written and
1077
- called: the python lines of a function `East.importFunction` linked in
1078
- included. Each input read lazily is an entry too, named as `-v` names it
1079
- (`input 1`): the time its reads spent decoding segments, a call each — keyed
1080
- reads at random beyond the segments the runner keeps, or a scan repeated,
1081
- which `-v`'s account counts — and not the reading function's own time.
1082
- `EAST_PROFILE_INTERVAL=300` adds the profile so far every five minutes while a
1083
- long task runs. east-node does not profile. Like `-v` it changes no hash: add
1084
- `--force` for a cached task.
1085
- **`E3_SCRATCH_DIR`** moves a local run's per-execution scratch directories
1086
- (default `<repo>/tmp/scratch`, on the object store's disk; on tmpfs, outputs sit
1087
- in memory until stored).
1088
-
1089
- **`repo gc`** keeps each workspace's last 10 runs (`--keep-runs`), every run
1090
- from the last 7 days (`--keep-days`) and the run its current state came from,
1091
- with every execution those runs used; every execution a workspace's current
1092
- state is served from, so a re-run stays cached; every execution from the last 7
1093
- days; and whatever is still running. An attempt recorded running that the local
1094
- runner says cannot finish is recorded interrupted, and goes as any that ended.
1095
- It then removes the objects nothing names, and staging files older than
1096
- `--min-age` (60 s). `--dry-run` reports what would go.
1097
-
1098
- A package zip names the release of e3 that exported it, and an import refuses a
1099
- zip a newer release exported, naming that release: import it with an e3 at least
1100
- as new as the SDK that exported it. A dataset upload names the transfer protocol
1101
- its e3 speaks, and a server refuses one that speaks another, naming both
1102
- releases and which of them to upgrade.
1103
-
1104
- ## Driving e3 from code
1105
-
1106
- **`@elaraai/e3-api-client`** talks to a server over HTTP. Every call is
1107
- `(url, repo, …, options)`, `options` being
1108
- `{ token: string | null, retry?, verbose?, fetch? }` (`e3 auth token <server>`
1109
- prints a token); `fetch` is the `fetch` every request of the call goes
1110
- through, the global one unless given — an in-page e3's `e3.fetch` (below).
1111
- Dataset paths are `TreePath`s — an input definition's `.path`, for one. A
1112
- request a workspace's lock refuses throws `ApiError` `workspace_locked`,
1113
- naming the holder: its pid, boot id, command and when it took the lock.
1114
-
1115
- | Area | Functions |
1116
- |---|---|
1117
- | Repositories | `repoList(url, opts)`, `repoCreate(url, name, opts)`, `repoRemove(url, name, opts)`, `repoStatus(url, repo, opts)`, `repoRecord` (its release and upgrades), `repoGc(url, repo, gcRequest, opts)` — a job it polls; `repoGcStart` and `repoGcStatus` apart |
1118
- | Packages | `packageList(url, repo, opts)`, `packageGet(url, repo, name, version, opts)`, `packageImport(url, repo, zipBytes, opts)`, `packageExport(url, repo, name, version, opts)` → zip bytes, `packageRemove` |
1119
- | Workspaces | `workspaceList`, `workspaceCreate(url, repo, ws, opts)`, `workspaceCopy(url, repo, from, to, opts)` → the target, made or replaced whole, `workspaceBundle(url, repo, ws, opts)` → the workspace as it is, as a bundle's bytes — its package, every dataset's ref, the executions its tasks' outputs come from, and every object those reach — and `workspaceBundleImport(url, repo, ws, bundle, opts)` → the workspace made from one under a name no workspace has, in another repository or another e3 (`workspace_exists`, `package_exists`, `bundle_invalid`), its tasks up to date with no run; a host mounts these routes where a bundle fits in a request: the local server, and e3-web, `workspaceGet`, `workspaceStatus(url, repo, ws, opts, { paths? })` — the whole workspace's, or the datasets named and the tasks producing them, `workspaceStatusSince(url, repo, ws, etag, opts, { paths? })` → `{ status, etag }`, or `null` while the status answered under `etag` is current (a poll sends the last answer's tag back; `null` asks in full), `workspaceLockStatus(url, repo, ws, opts)` → what holds the workspace and how far it says it has got (a deploy's files and records), or `null`, `workspaceRemove`, `workspaceDeploy(url, repo, ws, 'pkg@ver', opts, { schema?, inputs?, allowDropRecords?, plan?, onProgress? })` — a job it polls, whose progress while `deploying` is the deploy's own, answering what it did with each record, index and input, `workspaceExport(url, repo, ws, opts, { name?, version? })` → zip bytes. A poll's request takes `pollRequestOptions(opts)`: one attempt, its next poll being its retry |
1120
- | Datasets | `datasetGet(url, repo, ws, path, opts)` → `{ data, hash, size }` (a collection downloads as its segments), `datasetGetStream`, `datasetGetPage(…, window, opts)`, `datasetFindKey(…, query, opts)`, and several reads in one request (at most `DATASET_BATCH_MAX`, 10,000, each at one content hash, in a body of at most 16 MiB: a larger one is refused 413, `payload_too_large`): `datasetFindKeys(…, { queries, index?, hash? }, opts)` — key searches, `datasetGetRows(…, { keys, hash? }, opts)` — a Dict's rows by `.east` key, each with its position — or `datasetGetRows(…, { keysOf: { path, index, runs, hash }, hash? }, opts)`, by the keys the entries of some runs of another record's index name, which the server reads from the index so none is sent (a drawing's details for its window's cells), a stale `keysOf.hash` thrown as `RunsHashMismatchError` naming the record's content — and `datasetGetRuns(…, { runs, hash, index?, join? }, opts)` — the entries of several runs as one window, a rows or runs answer holding the first `count` the page budget reaches (by runs, of `runEntries`); and where a narrowing's rows sit in a record, from its index alone: `datasetPlace(…, { index, runs, offset?, limit?, hash }, opts)` → `{ segments, placed, runEntries, totalElements, hash }` — how many of the runs' entries each record segment holds (`{ segment, offset, count, rows }`), for the first `placed` of a window from `offset` (the next window from `offset + placed`), and `datasetWithin(…, { index, runs, keys, hash }, opts)` → `{ within, hash }` — whether each index entry key (`(ik=…, k=…)`) lies in one of the runs, `datasetSet(url, repo, ws, path, beast2Bytes, opts)`, `datasetSetStream(url, repo, ws, path, { size, hash, slice }, opts, { onCommitProgress? })` — a file of any size, the server's commit saying how far it has taken it in, `datasetList`, `datasetListAt`, `datasetListRecursive`, `datasetListWithStatus`, `datasetGetStatus` |
1121
- | Runs and tasks | `dataflowExecute(url, repo, ws, { force?, filter? }, opts, { pollInterval?, timeout? })` → the result (or `dataflowExecuteLaunch` and `dataflowExecutePoll`) — `force` is `true` or the names of the tasks to re-run, `filter` one task's exact name, `dataflowCancel` — with nothing running, `dataflow_error` ("No active execution for this workspace"), `dataflowGraph`, `dataflowBudget`, `taskList`, `taskGet`, `taskExecutionList(url, repo, ws, task, opts, { limit?, before? })` — a page of the task's runs, the latest first, each naming its `executionId`, the next page the runs `before` the last one's (100 a page unless `limit` says, 1,000 at most), `taskLogs(url, repo, ws, task, { stream?, offset?, limit?, execution? }, opts)` — a chunk of the log of the task's current execution, or of the one `execution` names (`{ inputsHash, executionId }`), the chunk naming its execution and whether it has `ended` |
1122
- | Functions | `functionList`, `functionDescribe`, `functionCall(url, repo, pkg, version, fn, { args, runner, limits }, opts)` — each argument `variant('value', beast2Bytes)`; the function runs on its own runner for any caller (`runner: none`); a runner the call names is never `custom`, and loads a platform package the function's does not only for an elevated caller; `workspaceFunctionList`, `…Describe`, `…Call(url, repo, ws, fn, request, opts)` — where an argument may also be `variant('dataset', path)`, a dataset of the workspace pinned at its hash, which the result names (`inputs`); `oneShotExecute` — a reader runs a platform-free one (stock runner, `platforms: []`, no platform call), and its result names the datasets it read (`inputs`); `splitCall(url, repo, ws, { bodyIr, args, output, then, runner, limits }, opts, { onProgress? })` — a program over a dataset's pieces, as a job it polls, under the same rule (or `splitCallLaunch`, `splitCallStatus` and `splitCallExplain`) |
1123
- | Records | `workspaceRecordDescribe`, `workspaceRecordMutate(url, repo, ws, record, mutation, { args, actor, limits }, opts, idempotencyKey?)`, `workspaceRecordHistory(url, repo, ws, record, limit, opts, from?)`, `workspaceRecordCompact` |
1124
- | From East | `Platform` and the `platform_*` functions (`platform_dataset_get`, `platform_dataflow_execute`, …): the same calls as platform functions, for an East program that drives a server |
1125
-
1126
- **`@elaraai/e3-core`** does the same on a local repository, given a storage
1127
- backend (`new LocalStorage()`) and the repository's path; work that runs East
1128
- takes a runner, `new LocalTaskRunner(repo)`.
1129
-
1130
- | Area | Functions |
1131
- |---|---|
1132
- | Repositories | `repoInit(path)`, `repoFind(startPath?)`, `repositoryOpen(storage, repo)` (checks the repository and applies the upgrades it owes), `repositoryUpgradeStep(storage, repo, { budgetMs, waitMs? })` → `{ owed }` — a host's job applies them so, a part per run under its time limit, each part taking a step up where the last stopped, `repoGc(storage, repo, { dryRun?, minAge?, keepRuns?, keepDays?, retention?, executionAlive? })` — holding the repository still, or, with `retention: { windowMs }`, beside running work: an object goes once unreachable for the window and not written or re-referenced since; given a runner's `executionAlive`, an attempt recorded running that cannot finish is recorded interrupted and pruned; `repoGcStep(storage, repo, step, { windowMs, pruneMs?, markMs?, concurrency?, executionAlive?, … })` runs that one step at a time, each returning the next (`GcStepType`), `pruneMs` and `markMs` bounding a prune step and a mark step for a host with a time limit |
1133
- | Packages | `packageImport(storage, repo, zipPath)`, `packageExport(storage, repo, name, version, zipPath)`, `packageList`, `packageRemove` |
1134
- | Workspaces | `workspaceCreate(storage, repo, ws)`, `workspaceCopy(storage, repo, from, to)`, `workspaceBundleExport(storage, repo, ws, writable, { have? })` — the workspace as a bundle to a WHATWG stream, leaving out the objects `have` says the receiving repository holds — and `workspaceBundleImport(storage, repo, ws, source)` — the workspace made from a bundle (a stream or chunks) under a name no workspace has, its objects stored as they come and its refs and record written once the repository holds everything they name, `workspaceDeploy(storage, repo, ws, pkgName, pkgVersion, options?)` (`runner`: its migrations, index builds and intake units; `schema` and `inputs`: its policies; `onRecordPlan`, `onRecordIndex`, `onInputPlan`: what it decided; `sourceConcurrency`: the `file` sources taken in at once; `onSourceProgress`, `onDeployProgress`: how far it has got), `workspaceExport(storage, repo, ws, zipPath, name?, version?)`, `workspaceStatus(storage, runner, repo, ws)`, `workspaceStatusRevision(storage, repo, ws)` — a token that moves whenever the status might, which the API's `ETag` names, `workspaceLockStatus(storage, repo, ws)`, `workspaceListStates(storage, repo)` — every workspace with its state in one read of the store, `workspaceRemove(storage, repo, ws, { sweep? })` — the record and what a store removes at once go in one call, and the rest is swept in bounded batches unless `sweep: false` leaves them to `workspaceSweep(storage, repo, cursor?)`, which a host with a time limit runs from a job |
1135
- | Datasets | `workspaceGetDataset(storage, repo, ws, treePath)`, `workspaceSetDataset(storage, repo, ws, treePath, value, type)`, `datasetAdoptFile(storage, repo, ws, treePath, file, { runner, onProgress? })` → `{ hash, size, segments, rows, taken, runners? }`, `taken` being `known`, `carried` or `taken` (by the `runners` named); `deliveryAdoptStored(storage, repo, ws, { address, type }, sha256, { runner?, onProgress?, signal? })` — a delivery the store holds taken in as a stored value of the type, naming no dataset, for a record's first state |
1136
- | Runs | `dataflowExecute(storage, repo, ws, options?)`; `LocalOrchestrator` to start, poll and cancel a run |
1137
- | Records | `recordMutate(storage, runner, repo, ws, record, mutation, args, { actor })`, `recordHistory`, `recordDescribe`, `recordCompact`, `recordReindex`; `recordSystemCommit(storage, runner, repo, ws, record, { name, target, actor, args? })` — `$rollback` to a commit, `$restore` of a state at the record's migrations, and `$init` on a record declared with no initial value: its first state, from a stored value, with the whole chain applied |
1138
-
1139
- `@elaraai/e3-core/test` exports the contract suites another storage backend runs
1140
- over itself.
1141
-
1142
- **`e3-api-server`** serves repositories: `--repos <dir>` (each subdirectory a
1143
- repository) or `--repo <path>` (one, served as `default`), `-p`/`--port` (3000),
1144
- `-H`/`--host` (localhost), `--cors`, `-j`/`--memory` (the server's budget, for
1145
- every run and call it serves and every upload it takes in), and auth — `--oidc`, a built-in provider for `e3
1146
- auth login` (`--token-expiry`, `--refresh-token-expiry`), or an external JWT
1147
- issuer (`--auth-key`, `--auth-issuer`, `--auth-audience`). In code,
1148
- `createServer({ reposDir | singleRepoPath, port, host, … })` starts one, and its
1149
- route factories mount on another host.
1150
-
1151
- ## Running e3 in a browser — `@elaraai/e3-web`
1152
-
1153
- e3-web runs e3 entirely in a page, with no server: a repository kept in the
1154
- browser's own storage (records in IndexedDB, objects in OPFS, locks through
1155
- Web Locks), every East program on a pool of Web Workers, and e3's whole API
1156
- answered in the page by e3-api-server's own routes. An app is three scripts:
1157
-
1158
- ```typescript
1159
- // unit.worker.ts — where East programs run: east-web-std answers for east-node-std's
1160
- // platform functions, and e3's own (e3-api-client's Platform) reach the e3 worker
1161
- import { serveUnits } from '@elaraai/e3-web/units';
1162
- serveUnits();
1163
- ```
1164
-
1165
- ```typescript
1166
- // e3.worker.ts — e3 itself: its storage, orchestrator, runner and API
1167
- import { serveE3 } from '@elaraai/e3-web/worker';
1168
- serveE3({
1169
- units: () => new Worker(new URL('./unit.worker.ts', import.meta.url), { type: 'module' }),
1170
- });
1171
- ```
1172
-
1173
- ```typescript
1174
- // main.ts — the page: e3-api-client's calls, every one answered by the e3 worker
1175
- import { createWebE3 } from '@elaraai/e3-web';
1176
- import {
1177
- dataflowExecute, packageImport, repoCreate, repoList, workspaceCreate, workspaceDeploy,
1178
- } from '@elaraai/e3-api-client';
1179
-
1180
- const e3 = await createWebE3(new Worker(new URL('./e3.worker.ts', import.meta.url), { type: 'module' }));
1181
- const opts = { token: null, fetch: e3.fetch };
1182
-
1183
- // The first visit makes the repository; later visits find it where they left it.
1184
- if (!(await repoList(e3.apiUrl, opts)).includes('default')) {
1185
- await repoCreate(e3.apiUrl, 'default', opts);
1186
- // The package zip e3.export wrote at build time, served beside the page
1187
- const zip = new Uint8Array(await (await fetch('/sales-planning-1.0.0.zip')).arrayBuffer());
1188
- const { name, version } = await packageImport(e3.apiUrl, 'default', zip, opts);
1189
- await workspaceCreate(e3.apiUrl, 'default', 'main', opts);
1190
- await workspaceDeploy(e3.apiUrl, 'default', 'main', `${name}@${version}`, opts);
1191
- await dataflowExecute(e3.apiUrl, 'default', 'main', {}, opts);
1192
- }
1193
- ```
1194
-
1195
- `e3.apiUrl` is `https://e3-web.invalid`, an origin reserved so that a request
1196
- sent without `e3.fetch` fails rather than reaching the network, and
1197
- `e3.fetch`, the global `fetch`'s signature, is answered by the e3 worker. Both
1198
- go to e3-api-client (`RequestOptions.fetch`) and to e3-ui-components'
1199
- `<E3Provider>` (`E3Config.fetch`: the **e3-ui** skill). An app's own platform
1200
- package is served beside the standard ones:
1201
- `serveUnits({ platforms: { '@acme/pricing': PricingPlatform } })`.
1202
-
1203
- | `serveE3` option | Default | Effect |
1204
- |---|---|---|
1205
- | `units` | — | starts a unit worker: a Web Worker whose script calls `serveUnits()` |
1206
- | `width` | the cores | the most units that run at once, and so the most unit workers, each with a heap of its own |
1207
- | `persist` | `true` | `false` keeps repositories in memory, gone with the page |
1208
- | `name` | `'e3'` | the storage's name: e3 workers of one name share their repositories, in one tab or several |
1209
- | `identify` | none | each request's caller, `{ sub, email?, roles }`, from the request; a request to a repository whose caller it does not identify is answered 401. None: the page's one caller may do everything |
1210
- | `access` | `oneShotAccessByRoles()` with `identify`, else `any` | the grant a caller holds for a one-shot, a split call, or a function call naming its own runner |
1211
- | `wholeIntakeLimit` | 256 MiB | the largest delivery one intake unit takes in whole |
1212
-
1213
- What works is the API, as the local server answers it: every API suite of
1214
- e3-api-tests passes against it in Chromium, as an admin and, in its reader
1215
- cases, as a reader. Paged reads and key search, function calls, one-shot and
1216
- split calls, record mutations, deploys that migrate records or build indexes,
1217
- uploads, package import and export, gc, and dataflow runs — tasks in parallel
1218
- up to the pool's width (the cores), split tasks in pieces, re-run reactively.
1219
- A repository outlives a reload, and two tabs share an origin's repositories as
1220
- two processes share a directory. A closed tab's locks are free; a run it left
1221
- is taken as one whose process died, the next run served what finished from
1222
- the cache; and a job or an upload's commit it left is recorded failed, never
1223
- run again.
1224
-
1225
- What a browser cannot do — each fails naming it, never a partial answer:
1226
-
1227
- - **Commands.** A custom task, or a task on the `custom` runtime, is recorded
1228
- `error`: "a browser runs no commands".
1229
- - **Platform functions with no browser meaning.** east-web-std has no
1230
- FileSystem, Env or large-JSON reader, and east-node-io and the python
1231
- packages have no browser equivalent: a unit calling one fails naming the
1232
- function, and one listing a package its worker does not serve fails naming
1233
- the package.
1234
- - **Segments on demand.** A unit's inputs are staged whole into its worker:
1235
- waiting for a segment needs a cross-origin isolated page, which GitHub Pages
1236
- cannot give. Split a large input into pieces with `e3.partition`, which
1237
- bounds a unit's memory anywhere; a delivery that cannot be cut into pieces
1238
- is refused above `wholeIntakeLimit`, naming the fix.
1239
- - **A memory budget.** Memory is not measured: the pool is as wide as the
1240
- cores, there is no `--memory`, and no record names a peak.
1241
- - **The CLI.** `e3` drives e3 over HTTP, which an in-page e3 does not serve.
1242
-
1243
- ## A local repository
1244
-
1245
- ```
1246
- repo/
1247
- ├── repository.beast2 # the release that last wrote it, and the upgrades it has had
1248
- ├── repository-upgrade.beast2 # while an upgrade is under way: where its last part stopped
1249
- ├── metadata.beast2 # its name and status
1250
- ├── objects/ # content-addressed: values, segments, manifests, programs
1251
- ├── packages/ # package refs
1252
- ├── workspaces/ # each workspace's state, dataset refs, and its latest run's state and events
1253
- ├── dataflows/ # run records
1254
- ├── executions/ # execution attempts: status, owner, logs
1255
- ├── running/ # an index of the attempts recorded running, by task: what a status reads
1256
- ├── runs/ # an index of each task's runs, its units left out: what its history and logs read
1257
- ├── adoptions/ # the manifest each delivered file, or piece of one, became
1258
- ├── locks/ # locks, their holders, and how far each says it has got
1259
- ├── gc/ # gc beside running work: unreachable notes, a stepped run's parts
1260
- ├── envs/ # built execution environments
1261
- └── tmp/ # scratch and staged uploads
1262
- ```
1263
-
1264
- An e3 opening a repository an older release wrote applies the upgrades it has
1265
- not had, in place; one a newer e3 upgraded is refused, naming that release.
478
+ ## Caching
1266
479
 
1267
480
  **Caching.** An execution is keyed by its task — program, runner and
1268
481
  environment — and its inputs' hashes, so a task re-runs only when one of those
@@ -1280,6 +493,20 @@ consumers, even during a run. A split task is cached a unit at a time: each piec
1280
493
  and each merge is its own execution, and pieces are cut by content, so an append
1281
494
  or an insertion re-runs only the pieces it reaches and the merges above them.
1282
495
 
496
+ ## Reference files
497
+
498
+ Read the one a task needs; each holds its subject whole.
499
+
500
+ | File | Holds |
501
+ |---|---|
502
+ | [reference/record-indexes.md](reference/record-indexes.md) | Secondary indexes, interval and area indexes, series and summary indexes, nested series indexes |
503
+ | [reference/record-migrations.md](reference/record-migrations.md) | `migration.value` / `rows` / `rekey`, and how a record's type changes |
504
+ | [reference/cli.md](reference/cli.md) | Every `e3` command: repositories, packages, workspaces, datasets, tasks, runs, calls, records, watch, convert, auth, gc |
505
+ | [reference/from-code.md](reference/from-code.md) | `@elaraai/e3-api-client`, `@elaraai/e3-core`, `e3-api-server` |
506
+ | [reference/browser.md](reference/browser.md) | `@elaraai/e3-web`: serveUnits, serveE3, createWebE3, and what a browser cannot do |
507
+ | [reference/rack.md](reference/rack.md) | `e3 rack enroll` / `policy`, routing a run to a rack, `@elaraai/e3-rack` |
508
+ | [reference/repository.md](reference/repository.md) | A local repository's layout, and upgrades |
509
+
1283
510
  ## Related skills
1284
511
 
1285
512
  - **east** — the language task bodies are written in.