@0xbuff/throughline 0.0.1 → 0.0.2
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.
- package/CHANGELOG.md +19 -20
- package/COPYRIGHT.md +5 -12
- package/README.md +19 -21
- package/package.json +2 -3
- package/docs/architecture.md +0 -93
- package/docs/authoring.md +0 -54
- package/docs/catalog.md +0 -96
- package/docs/grammar.md +0 -97
package/CHANGELOG.md
CHANGED
|
@@ -1,27 +1,26 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
Notable
|
|
4
|
-
|
|
5
|
-
schema version `1`.
|
|
3
|
+
Notable changes to Throughline are recorded here. Package versions follow
|
|
4
|
+
Semantic Versioning independently of the version-1 trace and program schemas.
|
|
6
5
|
|
|
7
|
-
## [0.0.
|
|
6
|
+
## [0.0.2] — 2026-11-08
|
|
8
7
|
|
|
9
|
-
|
|
8
|
+
### Changed
|
|
10
9
|
|
|
11
|
-
|
|
10
|
+
- Updated the npm package homepage to the Throughline documentation site.
|
|
11
|
+
- Refined installation, styling, security and maintenance documentation.
|
|
12
|
+
- Replaced first-release-specific staging logic with reusable, version-checked
|
|
13
|
+
signed-tag and provenance publishing.
|
|
14
|
+
- Removed obsolete public-release planning records and excluded source-only
|
|
15
|
+
development documentation from the npm tarball.
|
|
12
16
|
|
|
13
|
-
|
|
14
|
-
- Version-1 `Program` and `Trace` formats with source diagnostics and
|
|
15
|
-
deterministic frame seeking.
|
|
16
|
-
- Five supported domains: `flow`, `bindings`, `binary`, `matrix`,
|
|
17
|
-
and `callstack`.
|
|
18
|
-
- Optional React 19 player with keyboard playback, captions, state
|
|
19
|
-
inspection, responsive layouts, reduced motion and optional sound.
|
|
20
|
-
- Explicitly namespaced CSS, typed ESM exports and copyable examples.
|
|
21
|
-
- Independent Node, TypeScript, SSR, Chromium and Vite hydration tests.
|
|
22
|
-
- Apache-2.0 license and 0xBUFF attribution.
|
|
17
|
+
## [0.0.1] — 2026-11-08
|
|
23
18
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
Initial public release:
|
|
20
|
+
|
|
21
|
+
- Deterministic, bounded Markdown-authored state-trace compiler.
|
|
22
|
+
- Version-1 `Program` and `Trace` with diagnostics and deterministic seeking.
|
|
23
|
+
- Flow, bindings, binary, matrix and callstack domains.
|
|
24
|
+
- Optional React 19 player with keyboard playback, captions, state inspector,
|
|
25
|
+
responsive layouts, reduced-motion support and opt-in sound.
|
|
26
|
+
- Four explicit typed ESM/CSS exports, Apache-2.0 license and 0xBUFF attribution.
|
package/COPYRIGHT.md
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
# Copyright and
|
|
1
|
+
# Copyright and license
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Copyright 2026 0xBUFF.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Throughline is licensed under the Apache License, Version 2.0.
|
|
6
|
+
See [LICENSE](LICENSE) for the full terms.
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
for its terms.
|
|
9
|
-
|
|
10
|
-
"0xBUFF" is the maintainer-designated project copyright attribution. This
|
|
11
|
-
notice does not represent that the brand is incorporated as a separate legal
|
|
12
|
-
entity, or that a transfer of underlying copyright title has occurred. The
|
|
13
|
-
maintainer must verify authorship, legal ownership and redistribution rights
|
|
14
|
-
before a public source or npm release. Third-party attribution obligations
|
|
15
|
-
are reviewed separately; no third-party code is bundled in this package.
|
|
8
|
+
Third-party dependencies retain their respective licenses and notices.
|
package/README.md
CHANGED
|
@@ -12,11 +12,6 @@ operation, a recursive call or a system workflow. Throughline does not
|
|
|
12
12
|
execute arbitrary code or require an account, server, network connection
|
|
13
13
|
or application-specific runtime.
|
|
14
14
|
|
|
15
|
-
> **Release status:** GitHub source is public and npm version `0.0.1`
|
|
16
|
-
> is prepared for release. Check the registry for actual publication and
|
|
17
|
-
> provenance; see [release operations](RELEASING.md).
|
|
18
|
-
> The historical private planning reference still needs review.
|
|
19
|
-
|
|
20
15
|
## Features
|
|
21
16
|
|
|
22
17
|
- **Author in Markdown:** write a `thl` code fence with explicit, named steps.
|
|
@@ -33,7 +28,7 @@ or application-specific runtime.
|
|
|
33
28
|
|
|
34
29
|
## Installation
|
|
35
30
|
|
|
36
|
-
|
|
31
|
+
Install the package from npm:
|
|
37
32
|
|
|
38
33
|
~~~sh
|
|
39
34
|
npm install @0xbuff/throughline
|
|
@@ -93,8 +88,11 @@ export function TraceDemo() {
|
|
|
93
88
|
}
|
|
94
89
|
~~~
|
|
95
90
|
|
|
96
|
-
Import the stylesheet once in the host application. The player accepts
|
|
91
|
+
Import the optional stylesheet once in the host application. The player accepts
|
|
97
92
|
`light`, `dark` or `auto` themes and supports `--thl-*` CSS variables.
|
|
93
|
+
Override those variables using the player's `className` prop and a host
|
|
94
|
+
stylesheet loaded after the package CSS. A complete custom stylesheet is
|
|
95
|
+
also possible, but must provide the required layout and accessibility styles.
|
|
98
96
|
Pass a stable trace reference while stepping; replacing it resets playback.
|
|
99
97
|
Audio controls are absent unless you explicitly supply `sonification`.
|
|
100
98
|
|
|
@@ -138,21 +136,22 @@ React-free, network-free and usable in offline tooling.
|
|
|
138
136
|
render a responsive scene, controls, captions and an inspectable state.
|
|
139
137
|
Seeking a frame does not execute the source a second time.
|
|
140
138
|
|
|
141
|
-
Trace schema version `1` is
|
|
139
|
+
Trace schema version `1` is independent of the npm package version.
|
|
142
140
|
Source length is capped at 262,144 UTF-16 code units; the authored
|
|
143
141
|
program is limited to 200 entities, 1,000 relations, 2,000 steps and
|
|
144
142
|
10,000 events, plus work/expansion budgets. These limits are for
|
|
145
143
|
deterministic work, not a guarantee of exact heap or CPU usage.
|
|
146
144
|
|
|
147
|
-
For
|
|
145
|
+
For the complete guide, see the [Throughline documentation](https://docs.0xbuff.com/docs/throughline) and the [architecture notes](https://github.com/0xbuffdev/throughline/blob/main/docs/architecture.md).
|
|
148
146
|
|
|
149
147
|
## Documentation
|
|
150
148
|
|
|
151
|
-
- [
|
|
152
|
-
- [
|
|
153
|
-
- [
|
|
154
|
-
- [
|
|
155
|
-
- [
|
|
149
|
+
- [Throughline documentation](https://docs.0xbuff.com/docs/throughline)
|
|
150
|
+
- [Grammar and authored flow](https://github.com/0xbuffdev/throughline/blob/main/docs/grammar.md)
|
|
151
|
+
- [Domain catalog and domain-specific limits](https://github.com/0xbuffdev/throughline/blob/main/docs/catalog.md)
|
|
152
|
+
- [Architecture, trace format and runtime boundaries](https://github.com/0xbuffdev/throughline/blob/main/docs/architecture.md)
|
|
153
|
+
- [Adding a computed domain](https://github.com/0xbuffdev/throughline/blob/main/docs/authoring.md)
|
|
154
|
+
- [Changelog](https://github.com/0xbuffdev/throughline/blob/main/CHANGELOG.md)
|
|
156
155
|
|
|
157
156
|
## Development
|
|
158
157
|
|
|
@@ -173,20 +172,19 @@ pnpm audit:browser
|
|
|
173
172
|
~~~
|
|
174
173
|
|
|
175
174
|
The packed-consumer audits install the built archive into independent
|
|
176
|
-
Node, TypeScript, React SSR and Vite/browser environments.
|
|
177
|
-
does not, by itself, authorize a public release.
|
|
175
|
+
Node, TypeScript, React SSR and Vite/browser environments.
|
|
178
176
|
|
|
179
177
|
## Community
|
|
180
178
|
|
|
181
|
-
Read [contributing guidelines](CONTRIBUTING.md) before opening a PR.
|
|
179
|
+
Read [contributing guidelines](https://github.com/0xbuffdev/throughline/blob/main/CONTRIBUTING.md) before opening a PR.
|
|
182
180
|
Use [GitHub issues](https://github.com/0xbuffdev/throughline/issues)
|
|
183
181
|
for reproducible bugs and feature proposals; see
|
|
184
|
-
[SUPPORT.md](SUPPORT.md) for support and [SECURITY.md](SECURITY.md)
|
|
182
|
+
[SUPPORT.md](https://github.com/0xbuffdev/throughline/blob/main/SUPPORT.md) for support and [SECURITY.md](https://github.com/0xbuffdev/throughline/blob/main/SECURITY.md)
|
|
185
183
|
for confidential vulnerability reports. Participation is governed by
|
|
186
|
-
the [code of conduct](CODE_OF_CONDUCT.md).
|
|
184
|
+
the [code of conduct](https://github.com/0xbuffdev/throughline/blob/main/CODE_OF_CONDUCT.md).
|
|
187
185
|
|
|
188
186
|
## License
|
|
189
187
|
|
|
190
|
-
Licensed under [Apache-2.0](LICENSE).
|
|
191
|
-
Copyright 2026 0xBUFF; see [COPYRIGHT.md](COPYRIGHT.md).
|
|
188
|
+
Licensed under [Apache-2.0](https://github.com/0xbuffdev/throughline/blob/main/LICENSE).
|
|
189
|
+
Copyright 2026 0xBUFF; see [COPYRIGHT.md](https://github.com/0xbuffdev/throughline/blob/main/COPYRIGHT.md).
|
|
192
190
|
The license covers software rights under its terms, not trademark use.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xbuff/throughline",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "Readable state over time, authored in Markdown. A deterministic trace compiler with an optional React player.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -33,7 +33,6 @@
|
|
|
33
33
|
"files": [
|
|
34
34
|
"dist",
|
|
35
35
|
"src/styles",
|
|
36
|
-
"docs",
|
|
37
36
|
"README.md",
|
|
38
37
|
"LICENSE",
|
|
39
38
|
"COPYRIGHT.md",
|
|
@@ -74,7 +73,7 @@
|
|
|
74
73
|
"publishConfig": {
|
|
75
74
|
"access": "public"
|
|
76
75
|
},
|
|
77
|
-
"homepage": "https://
|
|
76
|
+
"homepage": "https://docs.0xbuff.com/docs/throughline",
|
|
78
77
|
"keywords": [
|
|
79
78
|
"state-traces",
|
|
80
79
|
"visualization",
|
package/docs/architecture.md
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
# Throughline architecture
|
|
2
|
-
|
|
3
|
-
Throughline separates **authored programs**, **compiled snapshots**
|
|
4
|
-
and **optional presentation**. This allows the compiler to run in Node
|
|
5
|
-
build pipelines or other offline ESM environments without React or a DOM.
|
|
6
|
-
|
|
7
|
-
## Data flow
|
|
8
|
-
|
|
9
|
-
1. **Source:** `parseThl` reads one `thl <domain>` block (optionally
|
|
10
|
-
surrounded by Markdown backtick/tilde fences). It preserves source
|
|
11
|
-
line positions for diagnostics; parsing an entire Markdown document
|
|
12
|
-
belongs to the host application.
|
|
13
|
-
2. **Domain:** `compileAst` dispatches `flow` to the authored-program
|
|
14
|
-
parser. The four computed adapters parse small parameter languages
|
|
15
|
-
and build the same `Program` through a deterministic tracer.
|
|
16
|
-
3. **Validation:** `validateProgram` checks version, entity and relation
|
|
17
|
-
identifiers, event shapes, finite JSON-like values, targets,
|
|
18
|
-
overlapping writes, visibility and limits. Errors are surfaced
|
|
19
|
-
as `ProgramError` with diagnostics.
|
|
20
|
-
4. **Compilation:** `compileProgram` emits a version-1 `Trace` with frame
|
|
21
|
-
zero (the initial state) followed by an immutable snapshot for each
|
|
22
|
-
authored beat. Each frame records active/changed targets,
|
|
23
|
-
transfers, notes and any source information.
|
|
24
|
-
5. **Presentation:** `ThroughlinePlayer` derives a deterministic SVG
|
|
25
|
-
scene from these frames and lays out nodes/links for the available
|
|
26
|
-
width. Controls seek among precompiled frames instead of re-running
|
|
27
|
-
authoring code. Accessible captions and the inspector expose state
|
|
28
|
-
beyond the visual scene.
|
|
29
|
-
|
|
30
|
-
## Public module boundaries
|
|
31
|
-
|
|
32
|
-
| Module | Responsibility | React required? |
|
|
33
|
-
| --- | --- | --- |
|
|
34
|
-
| `@0xbuff/throughline` | Parsing, validation, compilation, tracer and types | No |
|
|
35
|
-
| `@0xbuff/throughline/react` | Accessible player and optional sonification | Yes, React 19 peer |
|
|
36
|
-
| `@0xbuff/throughline/examples` | Public sample inputs | No |
|
|
37
|
-
| `@0xbuff/throughline/styles/throughline.css` | Namespaced player CSS | No |
|
|
38
|
-
|
|
39
|
-
The root compiler does not fetch remote data or use runtime application
|
|
40
|
-
services. External consumers import only the declared public exports;
|
|
41
|
-
deep imports are deliberately unsupported.
|
|
42
|
-
|
|
43
|
-
## Trace format and compatibility
|
|
44
|
-
|
|
45
|
-
`Program.version` and `Trace.version` are both `1`, not the npm package
|
|
46
|
-
version. Each authored step yields one frame after the initial frame,
|
|
47
|
-
with state values, visibility and relevant event annotations.
|
|
48
|
-
|
|
49
|
-
A package upgrade that changes syntax, model types, trace meaning,
|
|
50
|
-
diagnostics, controls or CSS selectors is potentially breaking even
|
|
51
|
-
when the trace-schema version stays constant. Maintain fixtures,
|
|
52
|
-
regression tests and release notes for such changes.
|
|
53
|
-
|
|
54
|
-
## Work and validation limits
|
|
55
|
-
|
|
56
|
-
- Maximum source: **262,144 UTF-16 code units**.
|
|
57
|
-
- Program: **200 entities**, **1,000 relations**, **2,000 steps**,
|
|
58
|
-
**10,000 events**.
|
|
59
|
-
- Program payload budget: **1,000,000 deterministic work units**.
|
|
60
|
-
- Expanded trace budget: **8,000,000 deterministic work units**.
|
|
61
|
-
- Reject unsupported or cyclic/non-JSON input values and conflicting
|
|
62
|
-
overlapping writes with explicit diagnostics.
|
|
63
|
-
|
|
64
|
-
These are work/payload constraints, not exact memory or CPU
|
|
65
|
-
measurements. The four computed adapters apply their own domain limits;
|
|
66
|
-
see [the catalog](catalog.md).
|
|
67
|
-
|
|
68
|
-
## Playback and accessibility
|
|
69
|
-
|
|
70
|
-
The player uses SVG to render the active scene. It keeps entity identity
|
|
71
|
-
stable across changes, reserves layout space for future values,
|
|
72
|
-
supports responsive groups and bounded views of large values, and
|
|
73
|
-
provides a textual inspector. Keyboard navigation, native inputs,
|
|
74
|
-
live status, reduced-motion preferences and SSR/hydration behavior
|
|
75
|
-
are covered by browser and packed-consumer tests.
|
|
76
|
-
|
|
77
|
-
Sonification is explicitly opted into by the caller and is not
|
|
78
|
-
triggered merely by importing the package. Neither playback nor
|
|
79
|
-
compilation records grades or authenticates learners.
|
|
80
|
-
|
|
81
|
-
## Build and trust boundaries
|
|
82
|
-
|
|
83
|
-
`tsdown` produces ESM, declarations and JavaScript source maps for
|
|
84
|
-
the three JavaScript exports. The stylesheet is shipped separately.
|
|
85
|
-
The source package uses one Node 24/pnpm CI job to run compiler and
|
|
86
|
-
browser tests, inspect third-party dependency license files and
|
|
87
|
-
install a packed tarball in independent Node, TypeScript, SSR and
|
|
88
|
-
Vite/React consumers.
|
|
89
|
-
|
|
90
|
-
These checks are necessary but do not establish copyright ownership,
|
|
91
|
-
absence of all secrets, or public-release permission. The private
|
|
92
|
-
source history must be separately cleared before any public-source
|
|
93
|
-
cutover.
|
package/docs/authoring.md
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
# Throughline adapter authoring guide
|
|
2
|
-
|
|
3
|
-
How to add a computed domain. Copy `binary.ts` (simplest) or
|
|
4
|
-
`bindings.ts` (dynamic topology on static edges); keep the adapter
|
|
5
|
-
~100 lines plus tests.
|
|
6
|
-
|
|
7
|
-
## Recipe
|
|
8
|
-
|
|
9
|
-
1. **Syntax.** Define 2–5 lines of params in the fence body, e.g.
|
|
10
|
-
`a = 1011`. Iterate them with `sourceLines(ast)` (blank lines and `#`
|
|
11
|
-
comments skipped without shifting the original fence-relative numbers).
|
|
12
|
-
2. **Parse: `parseX(ast: ThlBlock): Params`.** Validate everything and throw
|
|
13
|
-
`ProgramError([{ message, line }])` — these fail the build with the
|
|
14
|
-
same rendering as grammar errors. Parse never computes.
|
|
15
|
-
3. **Build: `buildX(params: Params): Program`.** Run the ordinary
|
|
16
|
-
algorithm and narrate it with `tracer()`: `node`/`link` declarations
|
|
17
|
-
first, then one `step(label, body)` per micro-step using
|
|
18
|
-
`set`/`focus`/`send`/`note`. Use `group(name, "row" | "column" | "tree")`
|
|
19
|
-
to arrange a set of nodes. `tracer().get()` reads live state
|
|
20
|
-
between steps. Validate by compiling: `compileProgram` enforces
|
|
21
|
-
unknown targets, conflicting writes, and value shapes.
|
|
22
|
-
4. **Register.** Add the name to `DomainName` (`domains/types.ts`),
|
|
23
|
-
`SUPPORTED_DOMAINS`, and the `COMPUTED` dispatch table
|
|
24
|
-
(`domains/registry.ts`), all re-exported from the package index.
|
|
25
|
-
5. **Document.** Add a catalog entry: syntax, params, exactly which
|
|
26
|
-
micro-steps it emits, a minimal example, and its limits.
|
|
27
|
-
|
|
28
|
-
## Staging rules
|
|
29
|
-
|
|
30
|
-
The two staging rules live in `grammar.md` (one idea per beat;
|
|
31
|
-
`send` does not mutate) and bind computed adapters too. Two
|
|
32
|
-
adapter-specific additions:
|
|
33
|
-
- **Stable identities, changing visibility.** Predeclare nodes and links;
|
|
34
|
-
future objects and inactive references start with `hidden: true`.
|
|
35
|
-
Use `show("node", id)` / `hide("node", id)` and their `"link"` equivalents
|
|
36
|
-
to describe the current structure. Rebinding hides the previous reference
|
|
37
|
-
and shows its replacement in one step. A transfer cannot use a hidden link
|
|
38
|
-
or endpoint. Reserving layout space does not require showing future objects.
|
|
39
|
-
- **One source line = one beat** where the domain has source lines
|
|
40
|
-
(`bindings`); otherwise one computation step = one beat (`binary`
|
|
41
|
-
bits, `matrix` cells, `callstack` pushes/pops).
|
|
42
|
-
|
|
43
|
-
## Tests (same change, no exceptions)
|
|
44
|
-
|
|
45
|
-
- Parse: happy path plus every error branch (missing/duplicate/bad
|
|
46
|
-
operand, out-of-range) asserting the `/Line N/` message.
|
|
47
|
-
- Build: beat labels in order, final entity values, at least one
|
|
48
|
-
transfer assertion, and one failure/edge case (zero carry, rebind,
|
|
49
|
-
1×1 grid, depth 1).
|
|
50
|
-
- Registry: one routing test per domain in `__tests__/registry.test.ts`.
|
|
51
|
-
- From this standalone package root, run `pnpm test:run` and
|
|
52
|
-
`pnpm typecheck`, plus browser tests for interactive changes.
|
|
53
|
-
Avoid `describe.only`, `test.only`, and skipped tests; current CI
|
|
54
|
-
does not automatically reject them.
|
package/docs/catalog.md
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
# Throughline adapter catalog
|
|
2
|
-
|
|
3
|
-
Computed domains turn terse params into micro-step Programs. Each adapter
|
|
4
|
-
is `parse(ast) → params`, `build(params) → Program` (via `tracer()`),
|
|
5
|
-
routed by the fence domain in `compile`. Hand-authored traces stay on
|
|
6
|
-
`flow` (`grammar.md`); adapters exist only where humans should not
|
|
7
|
-
hand-write the steps.
|
|
8
|
-
|
|
9
|
-
## flow (hand-authored)
|
|
10
|
-
|
|
11
|
-
Core grammar: `node`, `link`, `step`, `set`, `focus`,
|
|
12
|
-
`send`, `note`, `show`, `hide`. The fallback for every domain without a computed
|
|
13
|
-
adapter — workflows, protocols, pipelines, git/CI, threat models.
|
|
14
|
-
See `grammar.md`. No limits beyond the engine caps (200 entities,
|
|
15
|
-
1000 relations, 2000 steps, 10000 events).
|
|
16
|
-
|
|
17
|
-
## bindings — variable slots, primitives vs references
|
|
18
|
-
|
|
19
|
-
```thl bindings
|
|
20
|
-
let a = 5
|
|
21
|
-
let b = a
|
|
22
|
-
b = 9
|
|
23
|
-
const list = [1, 2]
|
|
24
|
-
const alias = list
|
|
25
|
-
alias.push(3)
|
|
26
|
-
alias = [7]
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
- Statements: `let`/`const <name> = <json|name>`, `<name> = <json|name>`,
|
|
30
|
-
`<name>.push(<json>, …)`. One source line = one beat.
|
|
31
|
-
- Emits: a `Stack` lane (one slot per variable, `null` until declared)
|
|
32
|
-
plus a `Heap` lane (`o1`, `o2`, … per array/object literal). Copying a
|
|
33
|
-
reference sends a packet along a `var → heap` edge; pushing focuses
|
|
34
|
-
every variable sharing the object so the sync is visible.
|
|
35
|
-
- Limits: `const` is not enforced; no expressions, indexing, or methods
|
|
36
|
-
besides `push`; push targets arrays only. Future variables and heap objects
|
|
37
|
-
start hidden. Only current reference edges are visible; rebinding hides
|
|
38
|
-
the previous edge while retaining the heap object for other aliases.
|
|
39
|
-
|
|
40
|
-
## binary — ripple-carry addition
|
|
41
|
-
|
|
42
|
-
```thl binary
|
|
43
|
-
a = 1011
|
|
44
|
-
b = 0110
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
- Params: `a = <bits>`, `b = <bits>` (order free). Operands are 1–16
|
|
48
|
-
binary digits.
|
|
49
|
-
- Emits: `A`/`B` as `bits` nodes, a `Sum` row (MSB-first with a leading
|
|
50
|
-
carry-out slot, `·` placeholders), a `Carry` number. One beat per bit,
|
|
51
|
-
LSB first (`bit 0` …), then a `Result` beat: carries ripple visibly
|
|
52
|
-
because each beat sets its sum cell and the carry together.
|
|
53
|
-
- Limits: 16 bits; unsigned only. Final result is always width n+1
|
|
54
|
-
(leading zero when there is no carry-out).
|
|
55
|
-
|
|
56
|
-
## matrix — matrix multiplication
|
|
57
|
-
|
|
58
|
-
```thl matrix
|
|
59
|
-
A = [[1,2],[3,4]]
|
|
60
|
-
B = [[5,6],[7,8]]
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
- Params: `A = <grid>`, `B = <grid>` (order free). Grids are 1–4 rows of
|
|
64
|
-
1–4 finite numbers, all rows equal length, inner dimensions matching.
|
|
65
|
-
- Emits: `A`, `B`, `C` as `matrix` nodes (`C` starts as `·`), a `Terms`
|
|
66
|
-
work row, and `row`/`col` read edges. One beat per output cell in
|
|
67
|
-
row-major order: focuses the A row and B column cells, writes
|
|
68
|
-
`C[i][j]`, lands the pairwise products in `Terms`, and sends both
|
|
69
|
-
reads as packets. Notes carry the full `C[i][j] = t0 + t1 = total`
|
|
70
|
-
expansion.
|
|
71
|
-
- Limits: 4×4. No transpose/inverse/determinant — `flow` covers the rest.
|
|
72
|
-
|
|
73
|
-
## callstack — factorial recursion
|
|
74
|
-
|
|
75
|
-
```thl callstack
|
|
76
|
-
fact 4
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
- Params: one line, `fact <n>`, depth 1–6.
|
|
80
|
-
- Emits: `slot1…slotN` frame slots (`Call stack` lane, bottom-up) plus a
|
|
81
|
-
`Returns` row. Push beats run `fact(n)` down to `fact(1)` (`calls`
|
|
82
|
-
packets travel caller → callee); unwind beats pop each frame to `null`,
|
|
83
|
-
record its value, and send a `↩` packet; a final `done` beat lands the
|
|
84
|
-
total. Notes narrate the blocked-on / got-back arithmetic.
|
|
85
|
-
- Limits: factorial only, depth ≤ 6 (13 beats max). General calls,
|
|
86
|
-
branches, and prediction are future adapters.
|
|
87
|
-
|
|
88
|
-
## Planned (tier 2, lesson-on-demand)
|
|
89
|
-
|
|
90
|
-
Each is one `parse` + one `build()` on `tracer()`, ~100 lines with
|
|
91
|
-
tests — transcription of the `visualizer/` reference computations, never
|
|
92
|
-
bespoke SVG: `vectors` (dot-product geometry, SEF6), `gradient`
|
|
93
|
-
(descent + finite-difference compare, SEF6/AI3), `search` (binary
|
|
94
|
-
search, SEF3), `sort` (bubble/insertion, SEF3), `cache`/`race`/`tcp`
|
|
95
|
-
(SYS1–SYS4 simulators). Workflows never need adapters: `flow` + the
|
|
96
|
-
grammar covers them.
|
package/docs/grammar.md
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
# Throughline grammar reference — `thl flow`
|
|
2
|
-
|
|
3
|
-
Source of truth for hand-authored traces. AI lesson authors write this;
|
|
4
|
-
`compile` parses and validates it into snapshots. A host can call this during
|
|
5
|
-
its build or at runtime.
|
|
6
|
-
Parameterized domains (`bindings`, `binary`, `matrix`, `callstack`) are
|
|
7
|
-
documented in `catalog.md`; they compile to this same grammar.
|
|
8
|
-
|
|
9
|
-
## Fence
|
|
10
|
-
|
|
11
|
-
```thl flow
|
|
12
|
-
node input "Vector" in "Memory" as array = [1,2,3]
|
|
13
|
-
step "Load"
|
|
14
|
-
focus input
|
|
15
|
-
note "Vector in memory"
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
- Info string names the domain: ```` ```thl flow ````.
|
|
19
|
-
- Everything between the fences is the program. Surrounding prose carries
|
|
20
|
-
the concept; the fence carries only state and beats.
|
|
21
|
-
- Blank lines and `#` comment lines are ignored.
|
|
22
|
-
|
|
23
|
-
## Statements
|
|
24
|
-
|
|
25
|
-
| Statement | Syntax | Notes |
|
|
26
|
-
| --- | --- | --- |
|
|
27
|
-
| `group` | `group "<name>" as <row|column|tree>` | Arranges nodes sharing this group name; omitted groups use `row`. |
|
|
28
|
-
| `node` | `node <id> "<label>" [in "<lane>"] [as <view>] [hidden] [= <json>]` | Declares an entity. Missing value defaults to `null`. |
|
|
29
|
-
| `link` | `link <id> <from> -> <to> ["<label>"] [hidden]` | Declares a directed edge between two node ids. |
|
|
30
|
-
| `step` | `step "<label>"` | Opens a beat. Every `set`/`focus`/`send`/`note` after it belongs to it until the next `step`. |
|
|
31
|
-
| `set` | `set <target> = <json>` | Writes a JSON value into an entity or a position inside it. |
|
|
32
|
-
| `focus` | `focus [<target>, ...]` | Highlights entities/positions for this beat. Comma- or space-separated; may be empty. |
|
|
33
|
-
| `send` | `send <relation> [= <json>]` | Highlights a directed transfer along a link; payload appears in the caption. Value optional. |
|
|
34
|
-
| `note` | `note "<text>"` | Caption for this beat. |
|
|
35
|
-
| `show` / `hide` | `show node <id>` / `hide link <id>` | Changes persistent visibility; either verb accepts `node` or `link`. |
|
|
36
|
-
|
|
37
|
-
Groups, nodes, and links must come before the first `step`. Events before any
|
|
38
|
-
`step` fail the build.
|
|
39
|
-
|
|
40
|
-
## Targets and values
|
|
41
|
-
|
|
42
|
-
- Target: an entity id, optionally followed by positions: `arr`, `arr[3]`,
|
|
43
|
-
`grid[1][2]`, `cfg.mode`. Writes to impossible paths (indexing a
|
|
44
|
-
non-array, `.key` on a non-record, out-of-range index) fail the build
|
|
45
|
-
at compile time. `focus` targets only need a known entity id — a
|
|
46
|
-
position that never resolves simply never highlights. Arrays may grow
|
|
47
|
-
by exactly one (`arr[len]` appends); records may gain keys.
|
|
48
|
-
- Value: finite JSON. Quote strings (`"emit"`); arrays and objects are
|
|
49
|
-
supported. `NaN`/`Infinity` are rejected.
|
|
50
|
-
- Views (per node, `as <view>`): `auto`, `text`, `number`, `array`,
|
|
51
|
-
`stack`, `matrix`, `bits`, `record`. Unknown views fail the build.
|
|
52
|
-
- Lanes (per node, `in "<lane>"`): free-form grouping string rendered as
|
|
53
|
-
a group header (e.g. `"Memory"`, `"Output"`).
|
|
54
|
-
|
|
55
|
-
## Frames
|
|
56
|
-
|
|
57
|
-
Compilation emits frame 0 (`Initial state`, entity initial values) plus
|
|
58
|
-
one frame per `step`. Seeking is a snapshot lookup, never recompute.
|
|
59
|
-
|
|
60
|
-
- `set` updates the entity value for this and later frames; the beat's
|
|
61
|
-
`changed` list carries the raw target strings (e.g. `input[1]`).
|
|
62
|
-
- `focus` and `set` targets together form the beat's `active` list.
|
|
63
|
-
- `send` adds a transfer for this beat only.
|
|
64
|
-
- `note` appends to the beat's caption lines.
|
|
65
|
-
- `show` / `hide` changes visibility for this and later frames. Hidden nodes
|
|
66
|
-
retain their values and identities; links with hidden endpoints are omitted.
|
|
67
|
-
Declare future objects with `hidden`, then show them when they appear.
|
|
68
|
-
Conflicting visibility writes and transfers along hidden links or endpoints
|
|
69
|
-
fail compilation. Changes within a step are applied together.
|
|
70
|
-
|
|
71
|
-
## Two staging rules (learned the hard way)
|
|
72
|
-
|
|
73
|
-
1. **One idea per beat.** Square *then* add; carry *then* land. Fusing
|
|
74
|
-
two state changes into one step fuses their highlights and captions,
|
|
75
|
-
and a same-value write (e.g. `1² = 1` over `1`) shows no change highlight — only
|
|
76
|
-
the focus ring. Split beats stay legible.
|
|
77
|
-
2. **`send` does not mutate.** The edge highlights the transfer, but the
|
|
78
|
-
destination keeps its old value until a `set` writes it. To show state
|
|
79
|
-
sync, pair them across beats (`send feed = 4` on the Add beat, or a
|
|
80
|
-
`Carry` beat with only `send` followed by a `Land` beat with `set`).
|
|
81
|
-
|
|
82
|
-
## Limits
|
|
83
|
-
|
|
84
|
-
200 entities, 1000 relations, 2000 steps, 10000 events per program.
|
|
85
|
-
Overlapping writes to the same target (or its parent/child path) inside
|
|
86
|
-
one step fail: split into separate steps.
|
|
87
|
-
|
|
88
|
-
## Errors (line-aware, fail the build)
|
|
89
|
-
|
|
90
|
-
Line 2: Unknown view "sparkle". Use auto, text, number, array, stack, matrix, bits, record.
|
|
91
|
-
Line 4: Invalid target "a..x". Use an id, optionally followed by [index] or .key.
|
|
92
|
-
Line 5: Conflicting writes to "a[1]" in one step; split into separate steps.
|
|
93
|
-
|
|
94
|
-
`ProgramError` carries diagnostics with source lines where available.
|
|
95
|
-
Compiling a block throws on invalid syntax or state. A host build must invoke
|
|
96
|
-
the compiler to reject invalid content before publication; the Academy also
|
|
97
|
-
has a render-time error panel for malformed content.
|