Skip to content

Feat/runner kern run#480

Merged
cukas merged 48 commits into
mainfrom
feat/runner-kern-run
Jun 28, 2026
Merged

Feat/runner kern run#480
cukas merged 48 commits into
mainfrom
feat/runner-kern-run

Conversation

@cukas

@cukas cukas commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

What

Why

How

Checklist

  • tsc -b passes
  • pnpm test passes
  • pnpm test:kern passes
  • pnpm lint passes
  • kern review packages/ --recursive checked

KERN-Agon and others added 30 commits June 24, 2026 12:27
`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>
cukas added 18 commits June 25, 2026 03:27
# 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
@cukas cukas merged commit 40fe125 into main Jun 28, 2026
4 checks passed
@cukas cukas deleted the feat/runner-kern-run branch June 28, 2026 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants