Skip to content

Commit 0e20424

Browse files
committed
fix(recon-silly-ation): make edited src/ files build under rescript + add pnpm dev shim
Adds a dev-only pnpm shim so the ReScript compiler can actually run against the .res sources. Surprise finding: the repo has ~19 pre-existing build errors across 11 files — the ReScript tree has been accumulating bugs without anyone invoking `rescript build`. This commit fixes the two pre-existing errors that blocked the files I edited in bbe47d6, without expanding scope into the other 9 broken files. src/ArangoClient.res (pre-existing, line 37): - ReScript does not allow inline nested record types in field positions. Extracted `collections` and `edges` as named record types; the `client` record is unchanged at every use site. src/ConflictResolver.res (pre-existing, line 233): - Old code tried to reassign `byType = ...` inside a forEach, which never compiled — `let` bindings are immutable in ReScript. - Replaced with `ref<Belt.Map.String.t<_>>`, using `byType := ...` for updates and `byType.contents` for reads. Semantics preserved. package.json + pnpm-lock.yaml (NEW, dev-only shim): - devDependencies: rescript 11.1.4, @rescript/core 1.6.1. - `packageManager: pnpm@9.14.4` pinned so corepack does not trip on its stale-signature fetch-latest bug. - Marked private + PMPL-1.0-or-later. Primary runtime remains Deno; this shim exists only for ReScript toolchain invocation. .gitignore: - Added `*.bs.js` — rescript.json uses `in-source: true`, so compiled JS lands next to .res sources. Now excluded from git. Build-verify (rescript build, from scratch, PATH pointed at node 22.13.1): - src/ArangoClient.res COMPILES CLEAN - src/Pipeline.res COMPILES CLEAN - src/ConflictResolver.res COMPILES CLEAN - src/HaskellBridge.res COMPILES CLEAN All four files from the earlier partial-pattern fix (bbe47d6) now parse, type-check, and produce .ast + .cmi + .cmj outputs. Panic-attack assail: 13 -> 14 (one higher after this commit because the added `ref` counts as an allocation in the weighted score, not because a new dangerous pattern was introduced). NOT fixed in this commit (separate session material): - src/Deduplicator.res let reassignment + inline record - src/LLMIntegration.res TS-style `return` used in ReScript - src/LogicEngine.res multiple syntax errors - src/Protocol.res syntax error - src/Types.res syntax error - src/CLI.res 8+ syntax errors - tests/{ArangoClient,ConflictResolver,PackShipper}Test.res `let assert = ...` — `assert` is a reserved keyword The whole repo has never been successfully built in its current state (no lib/bs/ checked in, no `rescript build` step in the Justfile). The ReScript tree is effectively dead code today; bringing it green needs a dedicated session.
1 parent bbe47d6 commit 0e20424

5 files changed

Lines changed: 82 additions & 15 deletions

File tree

recon-silly-ation/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ erl_crash.dump
4141
# ReScript
4242
/lib/bs/
4343
/.bsb.lock
44+
# rescript.json uses `in-source: true` so .bs.js artifacts land next to .res;
45+
# exclude them so built output never gets committed.
46+
*.bs.js
4447

4548
# Python (SaltStack only)
4649
__pycache__/

recon-silly-ation/package.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "recon-silly-ation",
3+
"version": "0.1.0",
4+
"private": true,
5+
"description": "ReScript dev-dependency shim. Primary runtime is Deno; this file exists only so pnpm can install the ReScript compiler toolchain for build verification.",
6+
"license": "PMPL-1.0-or-later",
7+
"packageManager": "pnpm@9.14.4",
8+
"devDependencies": {
9+
"rescript": "11.1.4",
10+
"@rescript/core": "1.6.1"
11+
},
12+
"scripts": {
13+
"build": "rescript build",
14+
"clean": "rescript clean"
15+
}
16+
}

recon-silly-ation/pnpm-lock.yaml

Lines changed: 36 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

recon-silly-ation/src/ArangoClient.res

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,24 @@ external createDatabase: {..} => database = "Database"
3030
@send external all: aqlQuery => promise<array<Js.Json.t>> = "all"
3131

3232
// Client state
33+
// ReScript does not allow inline nested record types in record field
34+
// positions, so the collection groupings are declared as named record
35+
// types first.
36+
type collections = {
37+
documents: collection,
38+
conflicts: collection,
39+
resolutions: collection,
40+
}
41+
42+
type edges = {
43+
relationships: collection,
44+
}
45+
3346
type client = {
3447
db: database,
3548
config: config,
36-
collections: {
37-
documents: collection,
38-
conflicts: collection,
39-
resolutions: collection,
40-
},
41-
edges: {
42-
relationships: collection,
43-
},
49+
collections: collections,
50+
edges: edges,
4451
}
4552

4653
// Initialize ArangoDB client

recon-silly-ation/src/ConflictResolver.res

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -226,17 +226,22 @@ let detectConflicts = (documents: array<document>): array<conflict> => {
226226
})
227227

228228
// Detect version conflicts (same type, different versions)
229-
let byType = Belt.Map.String.empty
229+
// Build the per-type grouping via an explicit ref since ReScript's
230+
// `let` bindings are immutable; the old code tried to reassign
231+
// `byType` in-place, which never compiled.
232+
let byType = ref(Belt.Map.String.empty)
230233
documents->Belt.Array.forEach(doc => {
231234
let typeStr = documentTypeToString(doc.metadata.documentType)
232-
let existing = byType->Belt.Map.String.get(typeStr)
233-
byType = switch existing {
234-
| None => byType->Belt.Map.String.set(typeStr, [doc])
235-
| Some(docs) => byType->Belt.Map.String.set(typeStr, Belt.Array.concat(docs, [doc]))
236-
}
235+
let existing = byType.contents->Belt.Map.String.get(typeStr)
236+
byType :=
237+
switch existing {
238+
| None => byType.contents->Belt.Map.String.set(typeStr, [doc])
239+
| Some(docs) =>
240+
byType.contents->Belt.Map.String.set(typeStr, Belt.Array.concat(docs, [doc]))
241+
}
237242
})
238243

239-
byType->Belt.Map.String.forEach((typeStr, docs) => {
244+
byType.contents->Belt.Map.String.forEach((typeStr, docs) => {
240245
if Belt.Array.length(docs) > 1 {
241246
// Check if versions differ
242247
let versions = docs->Belt.Array.keepMap(d => d.metadata.version)

0 commit comments

Comments
 (0)