Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ jobs:
node: [20, 22]
steps:
- uses: actions/checkout@v7
- name: Checkout maps repo
uses: actions/checkout@v7
with:
repository: interscript/maps
path: _maps
- name: Symlink maps into ../maps
run: ln -s "$PWD/_maps" "$GITHUB_WORKSPACE/../maps"
- uses: actions/setup-node@v7
with:
node-version: ${{ matrix.node }}
Expand All @@ -28,11 +35,41 @@ jobs:
- run: npm run lint
- run: npm run format:check

isc-parity:
name: ISC parser parity (all 289 maps)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Checkout maps repo
uses: actions/checkout@v7
with:
repository: interscript/maps
path: _maps
- name: Symlink maps into ../maps
run: ln -s "$PWD/_maps" "$GITHUB_WORKSPACE/../maps"
- uses: actions/setup-node@v7
with:
node-version: "22"
cache: npm
- run: npm ci
- run: npm run build
- name: Parse all .isc files
run: npx tsx scripts/parse-all-isc.ts
- name: End-to-end parity (target 100%)
run: npx vitest run test/isc/end-to-end.test.ts

coverage:
name: Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Checkout maps repo
uses: actions/checkout@v7
with:
repository: interscript/maps
path: _maps
- name: Symlink maps into ../maps
run: ln -s "$PWD/_maps" "$GITHUB_WORKSPACE/../maps"
- uses: actions/setup-node@v7
with:
node-version: "22"
Expand Down
7 changes: 7 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"semi": false,
"singleQuote": false,
"trailingComma": "all",
"printWidth": 100,
"tabWidth": 2
}
67 changes: 67 additions & 0 deletions TODO.complete/01-isc-parser-typescript.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# 01 — ISC parser in TypeScript (direct .isc loading)

## Priority: P1

## Problem
The TS runtime only loads compiled JSON IR (produced by Ruby's JsonIR
compiler). It cannot parse `.isc` source files directly. This creates a
build-time dependency on Ruby for every map update.

For full language independence (the user's stated goal), the TS runtime
needs its own ISC parser.

## Current Architecture
```
.imp → Ruby DSL → Node → JsonIR → .json → TS runtime
.isc → Ruby ISC parser → (no bridge to Node yet)
```

## Target Architecture
```
.isc → Ruby ISC parser → Node → JsonIR → .json → TS runtime
.isc → TS ISC parser ──────────────────────────→ TS runtime (direct)
```

## Implementation

### Grammar
Port the Parslet grammar to Peggy (PEG parser generator for JS):

```
// grammar/isc.pegjs
isc_source
= _ system:system_block _ { return system }

system_block
= "system" _ code:quoted_string _? "{" body:block_item* _? "}" { ... }
```

### Structure
```
packages/isc-parser/
grammar/isc.pegjs # Peggy grammar
src/parser.ts # Wrapper API
src/document-builder.ts # Tree → typed model
test/parser.test.ts # Unit tests
test/parity.test.ts # Cross-validate with Ruby output
```

### API
```typescript
export function parseIsc(source: string, filename?: string): IscDocument
export function loadIscFile(path: string): Promise<IscDocument>
```

### Strategy Integration
Add an `iscStrategy` to the loader:
```typescript
const strategy = iscFileStrategy({ baseDir: "/maps" })
configure({ strategies: [strategy] })
```

This lets the runtime load `.isc` files directly without pre-compilation.

## Verification
- Parse all 289 .isc files with the TS parser
- Compare document model with Ruby parser output
- Run transliteration: output must match Ruby 100%
47 changes: 47 additions & 0 deletions TODO.complete/02-generate-full-parity.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# 02 — Generate full-parity fixtures for all 289 maps

## Priority: P0

## Current State
- `test/fixtures/parity.json` has only 40 curated fixtures (14 maps)
- `test/fixtures/full-parity.json` has 7502 fixtures but lives in .gitignore
- 2 maps have no IR (bgnpcgn-tuk-Cyrl-Latn-1979/1993)

## Fix

### 1. Generate IR for missing maps
The 2 missing maps fail Ruby DSL parsing. Options:
- Fix the Ruby DSL bug, OR
- Generate IR via ISC parser (once NodeAdapter is built, see TODO.complete/00)

### 2. Commit full-parity fixtures
```bash
ruby scripts/full-parity.rb > test/fixtures/full-parity.json
git add test/fixtures/full-parity.json
git add test/fixtures/maps/*.json
git commit -m "test: commit full-parity fixtures for all 289 maps"
```

### 3. Replace curated parity test with full-parity
Update `test/parity.test.ts` to use `full-parity.json` instead of
the curated `parity.json`:
```typescript
const FIXTURES = resolve(FIXTURES_DIR, "full-parity.json")
const payload = JSON.parse(readFileSync(FIXTURES, "utf8"))
for (const fx of payload.samples) {
it(`${fx.system_code}: ${JSON.stringify(fx.input)}`, () => {
expect(transliterate(fx.system_code, fx.input)).toBe(fx.ruby_actual)
})
}
```

### 4. CI integration
```yaml
# .github/workflows/parity.yml
- name: Regenerate fixtures
run: |
ruby scripts/full-parity.rb > test/fixtures/full-parity.json
npx tsx scripts/full-parity.ts
- name: Check no drift
run: git diff --exit-code test/fixtures/
```
Loading
Loading