Feat/runner kern run#480
Merged
Merged
Conversation
`kern run` parses a .kern file, locates the single `fn name=main returns=void`
whose `handler lang="kern"` body holds the program, executes it through the
ReferenceRunner (referenceRunSequence — the same executor the 3-leg parity suite
certifies), and replays its {op:'stdout'} trace events to real stdout. This is
the headline "KERN runs on its own" deliverable: the runtime becomes user-facing,
not just an internal differential oracle.
Slice-1 executable surface = the runner's certified set today: print / let /
assign / for / return + portable arithmetic. The compelling demo runs natively:
`let kind=let total=0; for i in 1..4: total += i; print total` -> 6.
Contract:
- Strict entry resolution: exactly one top-level void `fn main`, no params, not
async, exactly one `handler lang="kern"`. Anything else -> deterministic stderr
diagnostic + exit 2 (never a stack trace).
- FAIL-CLOSE atomicity: a non-portable op makes the runner abstain -> NO stdout,
exit 2 (a `print 1; print 3/2` leaks nothing — output is rendered only after the
whole body completes). Not-yet-executable constructs (if/while/each/try/throw,
arrays) abstain to exit 2 by design.
- Exit 0 on normal/return completion. Parses with the same Node capabilities as
`kern compile`; uses process.exitCode (not process.exit mid-write) so piped
stdout never truncates.
Oracle (RED-at-base; every expected byte verified empirically on the built runner):
- packages/cli/tests/run.test.ts — CLI behavior: entry resolution, exit codes,
fail-close atomicity.
- packages/python/tests/kern-run-cli-differential.test.ts — 3-leg CLI parity:
kern run === emitted-TS (node) === emitted-Python (python3).
Driver only — no runner/contract/emitter changes.
⚔️ Forged by [Agon](https://github.com/KERNlang/agon)
Co-Authored-By: agon (KERN) <292465531+KERN-Agon@users.noreply.github.com>
…ays are the real gap) The slice-1 oracle mischaracterized `if` as "not yet executable" — the test used the wrong attribute (`condition=` instead of the canonical `cond=`), so the parser kept an unknown prop and the contract abstained. With correct `cond=` syntax, `if`/`while` (incl. comparison conditions like `x > 3`) execute today and are 3-leg portable; arrays are the actual next gap. - Replace the misleading `if condition=` abstain test with a genuine gap-#2 abstain (array literal `let xs=[1,2,3]`, which has no runner evaluator yet). - Add if/else + while happy-path cases to the CLI oracle. - Add if/else + while to the 3-leg differential (kern run === ts === py). Test-only; no driver change. ⚔️ Forged by [Agon](https://github.com/KERNlang/agon) Co-Authored-By: agon (KERN) <292465531+KERN-Agon@users.noreply.github.com>
# Conflicts: # packages/cli/src/commands/rag.ts # packages/cli/tests/rag.test.ts # packages/cli/tests/run.test.ts # packages/core/src/index.ts # packages/core/src/rag-index-runner.ts # packages/core/src/rag-retrieve-runner.ts # packages/core/tests/rag-index-runner.test.ts # packages/core/tests/rag-retrieve-runner.test.ts # packages/python/tests/kern-run-cli-differential.test.ts
…runner-kern-run # Conflicts: # packages/cli/src/commands/rag.ts # packages/cli/tests/rag.test.ts # packages/core/src/rag-index-runner.ts # packages/core/src/rag-retrieve-runner.ts # packages/core/tests/rag-index-runner.test.ts # packages/core/tests/rag-retrieve-runner.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Why
How
Checklist
tsc -bpassespnpm testpassespnpm test:kernpassespnpm lintpasseskern review packages/ --recursivechecked