Commit 1656097
port(ts->affine): unit/evidence_graph_test → AffineScript (STEP 4-C SEED, Refs standards#239 / #243) (#91)
Estate-wide TypeScript→AffineScript migration campaign
(`hyperpolymath/standards#239`) — **first STEP 4-C per-repo port** (the
seed for tail batch 2, `standards#243`).
Mirrors the STEP-2 pattern shipped in session-sentinel#25 /
tropical-resource-typing#15 / nafa-app#23 / phronesis#19.
## What lands
- `tests/unit/evidence_graph_test.ts` (313L, 5 `Deno.test` blocks with
nested `t.step` subtests) → `tests/unit/evidence_graph_test.affine`
(333L AS source) + `tests/unit/evidence_graph_test.deno.js` (compiled
Deno-ESM artefact).
- `deno.json` `test:unit` task now drives the compiled `.deno.js`;
legacy `tests/unit/` runner kept as `test:unit-legacy` for any iteration
still in progress.
## Adaptations from the .ts source
### Test driver shape
Each `await t.step("…", () => { … })` flattens into a `pub fn
test_<name>() -> Bool` returning true/false with a `FAIL: <reason>` line
via `consoleError`. `main()` drives the 25-test list with a `run_one`
reporter and exits non-zero on any failure. Replaces `Deno.test`
discovery (gap 1 in standards#242 / deferred — panic-on-fail driver
works for STEP-2/4-C scope).
### TS interfaces → AS record types
```as
pub type Node = { id: String, label: String, node_type: String, prompt_score: Float }
pub type Link = { source: String, target: String, relationship: String }
pub type GraphData = { nodes: [Node], links: [Link] }
```
The TS source's `"claim" | "evidence" | string` union for `nodeType`
collapses to plain `String` (the union already allowed any string).
### TS throws → AS `Option<T>`
The Deno-ESM backend has no user-throwable exception surface, so
`create_node` / `create_link` `throw new Error(...)` on bad inputs
becomes `Option<Node>` / `Option<Link>` with `None` for rejected inputs.
Negative tests check for `None` via `check_none_node` /
`check_none_link`; the contract — "the factory rejects bad input" — is
preserved.
### Null-handling tests adaptation
The TS source's `null as unknown as string` casts are vacuous in
AffineScript (statically typed; no nullable strings). The representative
shape (empty-string inputs as a stand-in for "ill-formed input") is
retained as the AS equivalent, since that's what those tests ultimately
verified.
## Verification
```
$ node tests/unit/evidence_graph_test.deno.js
ok node: create claim node
ok node: create evidence node
ok node: custom type
ok node: reject empty id
ok node: reject empty label
ok node: reject negative prompt_score
ok node: reject prompt_score > 100
ok node: boundary prompt_score 0
ok node: boundary prompt_score 100
ok link: supports
ok link: contradicts
ok link: contextualizes
ok link: custom relationship
ok link: reject empty source
ok link: reject empty target
ok link: reject empty relationship
ok graph: empty
ok graph: with nodes
ok graph: with links
ok graph: complex
ok null: empty id rejected
ok null: empty label rejected
ok null: empty arrays graph
ok access: all node fields
ok access: all link fields
OK: all tests passed (25/25)
```
## Out of scope for this PR
Other bofig TS test files (the remaining 4 of the 5 files under
`tests/`):
- **`tests/property/graph_properties_test.ts`** (377L) — needs
`Math.random` binding, filed as `standards#327` / `affinescript#509`
(auto-merge armed).
- **`tests/bench/graph_bench.ts`** (252L) — same `Math.random` gating +
`Deno.bench` differs from `Deno.test`.
- **`tests/e2e/graph_lifecycle_test.ts`** (445L) and
**`tests/aspect/security_test.ts`** (459L) — independent ports; each
will be a follow-up STEP 4-C tail PR in this repo.
## Refs
- `hyperpolymath/standards#239` (umbrella) / `#243` (STEP 4 tail batch 2
— this issue)
- `hyperpolymath/standards#242` (STEP 3 predecessor)
- Sibling stdlib PRs (auto-merge armed): `affinescript#504` (STEP 3),
`affinescript#507` (STEP 4-A binary I/O), `affinescript#509` (STEP 4-B
random + perf.now)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 51c38dd commit 1656097
44 files changed
Lines changed: 2631 additions & 2108 deletions
File tree
- .github/workflows
- assets/js/hooks
- config
- docs
- lib/evidence_graph
- lithoglyph
- zotero
- priv/repo/migrations
- src
- tests
- aspect
- bench
- e2e
- property
- unit
- test
- evidence_graph
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
109 | 110 | | |
110 | 111 | | |
111 | 112 | | |
| 113 | + | |
112 | 114 | | |
113 | 115 | | |
114 | 116 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| 36 | + | |
| 37 | + | |
35 | 38 | | |
36 | 39 | | |
37 | 40 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
66 | 67 | | |
67 | 68 | | |
68 | 69 | | |
| 70 | + | |
69 | 71 | | |
70 | 72 | | |
71 | 73 | | |
| |||
115 | 117 | | |
116 | 118 | | |
117 | 119 | | |
| 120 | + | |
118 | 121 | | |
119 | 122 | | |
120 | 123 | | |
| |||
179 | 182 | | |
180 | 183 | | |
181 | 184 | | |
| 185 | + | |
182 | 186 | | |
183 | 187 | | |
184 | 188 | | |
| |||
237 | 241 | | |
238 | 242 | | |
239 | 243 | | |
| 244 | + | |
240 | 245 | | |
241 | 246 | | |
242 | 247 | | |
| |||
258 | 263 | | |
259 | 264 | | |
260 | 265 | | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
281 | 286 | | |
282 | 287 | | |
283 | 288 | | |
| |||
300 | 305 | | |
301 | 306 | | |
302 | 307 | | |
| 308 | + | |
303 | 309 | | |
304 | 310 | | |
305 | 311 | | |
| |||
378 | 384 | | |
379 | 385 | | |
380 | 386 | | |
381 | | - | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
| 15 | + | |
| 16 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
23 | 49 | | |
24 | 50 | | |
25 | 51 | | |
26 | 52 | | |
27 | 53 | | |
28 | 54 | | |
29 | | - | |
30 | | - | |
| 55 | + | |
| 56 | + | |
31 | 57 | | |
32 | 58 | | |
33 | 59 | | |
| |||
36 | 62 | | |
37 | 63 | | |
38 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
39 | 75 | | |
40 | 76 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| |||
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
56 | | - | |
57 | | - | |
| 57 | + | |
| 58 | + | |
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
| |||
411 | 412 | | |
412 | 413 | | |
413 | 414 | | |
414 | | - | |
| 415 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
18 | 31 | | |
| 32 | + | |
19 | 33 | | |
20 | 34 | | |
21 | 35 | | |
| |||
30 | 44 | | |
31 | 45 | | |
32 | 46 | | |
| 47 | + | |
33 | 48 | | |
0 commit comments