Skip to content

Commit b20b09f

Browse files
hyperpolymathclaude
andcommitted
docs(readiness): advance grade E → D after parser implementation
KRL parser is now implemented in KRLAdapter.jl (Julia, Option B). Lexer + recursive descent parser + AST + lowering all done; 5577 tests pass. Document grammar coverage, known gaps (typechecker, R2 simplify across compose boundaries), and path to C. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 327e0ff commit b20b09f

1 file changed

Lines changed: 83 additions & 46 deletions

File tree

READINESS.md

Lines changed: 83 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -4,62 +4,92 @@
44
# Component Readiness — KRL
55

66
**Standard:** [CRG v2.0 STRICT](https://github.com/hyperpolymath/standards/tree/main/component-readiness-grades)
7-
**Current Grade:** E
8-
**Assessed:** 2026-04-05 (promoted XE after iteration 1)
7+
**Current Grade:** D
8+
**Assessed:** 2026-04-12 (promoted ED after iteration 2)
99
**Assessor:** Jonathan D.A. Jewell
1010

1111
---
1212

13-
## Grade rationale (evidence for E — promoted from X)
13+
## Grade rationale (evidence for D — promoted from E)
1414

15-
Grade E criterion: "At least 1 test, documented failures."
15+
Grade D criterion: "Works on some inputs, test matrix present."
1616

1717
### Evidence
1818

19-
- **Grammar drafted:** `spec/grammar.ebnf` v0.1.0 — EBNF for all four KRL
20-
operation families (CONSTRUCT / TRANSFORM / RESOLVE / RETRIEVE)
21-
- **Grammar overview:** `spec/grammar-overview.md` — prose introduction,
22-
operator precedence, reserved words, known gaps
23-
- **Examples:** 4 runnable examples covering all 4 operation families
24-
- `examples/trefoil.krl` — CONSTRUCT + RESOLVE + TRANSFORM
25-
- `examples/figure_eight.krl` — CONSTRUCT + TRANSFORM
26-
- `examples/query-by-jones.krl` — CONSTRUCT + RESOLVE + RETRIEVE
27-
- `examples/tensor-and-close.krl` — CONSTRUCT with tensor + closure
28-
- **Smoke test:** `tests/smoke/grammar_smoke.sh` — 16 lexical checks against
29-
the examples, all passing. Validates terminator presence, paren balance,
30-
generator-argument shape, operation-family coverage.
31-
- **RSR compliance:** inherited from rsr-template-repo scaffold
32-
33-
### What was tested (16 assertions)
34-
35-
Per .krl example file:
36-
- Statement terminators (`;`) present
37-
- Parentheses balanced
38-
- No v0.2-reserved tokens (equivalent?, near, classify_by, prove) used prematurely
39-
- At least one operation family exercised
40-
41-
### What is NOT tested (honest — documented failures)
42-
43-
- **No parser.** The grammar is declared, not implemented. None of the
44-
examples have been parsed by code.
45-
- **No AST.** Nothing reads a .krl file into a structured form.
46-
- **No typechecker.** Port-arity compatibility not verified.
47-
- **No TangleIR compilation.** No path from .krl source to
48-
KRLAdapter.TangleIR yet.
49-
- **No error messages.** Absence of parser means absence of diagnostics.
19+
- **Parser implemented:** `KRLAdapter.jl/src/parser/` (Julia, Option B decision 2026-04-12)
20+
- `lexer.jl` — full lexer with position tracking, `KRLLexError`
21+
- `ast.jl` — all AST node types (`KRLProgram`, `KRLBinding`, `KRLGenerator`,
22+
`KRLCompose`, `KRLTensor`, `KRLPrefixOp`, `KRLParenExpr`, `KRLIdentifier`,
23+
`KRLQuery`, `KRLFilter`, `KRLIntValue`, `KRLStrValue`, `KRLIdentValue`)
24+
- `parser.jl` — recursive descent, full v0.1.0 grammar
25+
- `lower.jl` — AST → TangleIR lowering with `KRLLowerError`
26+
- **Grammar ambiguity resolved:** `;` as sequential composition only fires
27+
inside parenthesised expressions (`in_parens=true`); at statement level `;`
28+
is the terminator.
29+
- **Test matrix:** `KRLAdapter.jl/test/parser_test.jl` — 5 testsets, 57 tests
30+
- Lexer: keywords, identifiers, integers, strings, operators, punctuation,
31+
comments stripped, position tracking, lex error, unterminated string
32+
- Parser: 20 grammar cases including all generators, let bindings, sequential
33+
compose (with parens), tensor product, prefix ops, queries with `and` chains
34+
- Parser errors: missing `;`, unrecognised token, missing index, zero index
35+
- Example .krl files: all 4 examples in `krl/examples/` parse without error
36+
- Lowering: sigma/sigma_inv → TangleIR, compose, trefoil, mirror, let binding,
37+
unbound identifier error, query → KRLQueryPlan
38+
- **5577 tests pass** (full KRLAdapter.jl suite including parser tests)
39+
40+
### Grammar coverage
41+
42+
The implemented grammar (v0.1.0):
43+
44+
| Construct | Status |
45+
|-----------|--------|
46+
| `let` binding ||
47+
| `sigma`, `sigma_inv`, `cup`, `cap` generators ||
48+
| Sequential composition `(a ; b)` ||
49+
| Tensor product `a \| b` ||
50+
| `close`, `mirror`, `simplify`, `normalise`, `classify` ||
51+
| `find where` queries with `and` ||
52+
| Parenthesised sub-expressions ||
53+
| Identifier references (let-bound) ||
54+
| Line comments `--` ||
55+
| String, integer, identifier filter values ||
56+
57+
### What is NOT yet implemented (documented gaps — D grade)
58+
59+
- **No typechecker.** Port-arity compatibility (e.g. composing a 2-strand
60+
braid with a 3-strand tangle) not verified at parse time.
61+
- **R2 simplification across compose() boundaries.** `simplify_ir` detects
62+
R2 bigons by arc-index overlap, but `compose()` renumbers arcs so adjacent
63+
sigma/sigma_inv pairs are not detected. Tracked in `KRLAdapter.jl` issues.
64+
- **No pretty-printer.** `KRLProgram → string` round-trip not yet implemented.
65+
- **No RESOLVE family.** `classify` is parsed and lowered (identity) but
66+
not dispatched to the query layer.
5067

5168
---
5269

53-
## Path to D (alpha, test matrix + RSR)
70+
## Grade E rationale (retained for history)
71+
72+
Grade E criterion: "At least 1 test, documented failures."
73+
74+
### Evidence (iteration 1)
5475

55-
1. Choose parser implementation language (tangle OCaml host, KRLAdapter
56-
Julia, or sibling OCaml compiler — see `spec/grammar-overview.md`).
57-
2. Implement lexer + parser for v0.1.0 grammar.
58-
3. Define AST in chosen language.
59-
4. Add test matrix: parse tests (one per example), parse-fail tests (one
60-
per malformed input), roundtrip tests (AST → pretty-print → parse).
61-
5. Scope documentation in this file: what KRL programs parse, what KRL
62-
programs don't yet.
76+
- Grammar drafted: `spec/grammar.ebnf`, `spec/grammar-overview.md`
77+
- 4 examples in `examples/`
78+
- Shell smoke test: `tests/smoke/grammar_smoke.sh` (16 lexical assertions)
79+
80+
---
81+
82+
## Path to C (alpha-stable)
83+
84+
After D: typechecker (port-arity + generator index validity), deeper TangleIR
85+
compilation correctness, annotation per-directory, dogfooding by parsing 20+
86+
KRL programs from the knot table. Fix R2 simplification across compose()
87+
boundaries.
88+
89+
## Path to B (beta)
90+
91+
After C: 6+ diverse external targets (knot researchers, DSL authors,
92+
topology educators) write KRL programs and report back.
6393

6494
## Path to C (alpha-stable)
6595

@@ -86,10 +116,17 @@ Templated from rsr-template-repo. Zero KRL-specific content.
86116
- 4 examples/ programs
87117
- tests/smoke/grammar_smoke.sh (16 lexical assertions, all passing)
88118

119+
### Iteration 2 (promoted to D — 2026-04-12)
120+
- Decision: Option B — Julia in KRLAdapter.jl
121+
- Implemented: lexer, AST, recursive-descent parser, lowering (KRLAdapter.jl)
122+
- Grammar ambiguity fixed: `;` as compose only inside parentheses
123+
- 57 dedicated parser tests + all 4 example files parse cleanly
124+
- 5577 total KRLAdapter.jl tests pass
125+
89126
## Review cycle
90127

91-
Reassess on first parser implementation milestone, or if examples drift
92-
from what the grammar admits.
128+
Reassess on typechecker implementation or when 20+ knot-table programs
129+
have been parsed successfully.
93130

94131
---
95132

0 commit comments

Comments
 (0)