Commit Graph
77 Commits
Author SHA1 Message Date
coolguyandClaude Opus 5 0a434d8a9a spec: record why the try rule cannot be enforced yet
SPEC.md allows `try` only inside a function returning an error union, but
check.c only tests it in the FE_N_EXPR_STMT case, so `var x = try e;` and
`x = try e;` walk straight past. m5/owned.fe and m5/runtime.fe both depend on
that gap.

Moving the check onto the try expression is a four-line change and it is
correct, but it cannot land yet. runtime.fe's `run` allocates and returns a
value, so closing the hole forces it to return an error union -- and master
rejects `return <value>;` in `-> !i32` ("return type mismatch") as well as a
bare `return;` in `-> !void` ("void expression returned from value function").
Both need contextual success construction, which is M7 work. `catch` and
`@trap()`, the two spellings SPEC offers as alternatives, are also M7-only, so
there is no way to express `run` legally on master today. All three paths were
tried in DOSBox-X, not assumed.

Fix owned.fe now, since `main() -> !void` is legal today and matches
m4/try-fpr.fe, and leave the checker alone until M7 lands with the rest.

Verified: 155 passed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BScg8CF1sAAM2zVHAu5zvW
2026-08-16 23:23:47 +09:00
coolguyandClaude Opus 5 86bff9a06d dev: capture compiler diagnostics under DOS
Every fec error message was written to stderr, and COMMAND.COM can only
redirect handle 1 -- ">" is the whole vocabulary, "2>" is not parsed at all.
So a failing compile recorded exit code 1 and a zero-byte log, and the actual
message went to a screen nobody reads. Confirmed directly: `FEC.EXE --check`
on a fixture that must fail produced rc=1 and 0 bytes of stdout.

That is why an unexpected compiler failure was undiagnosable. It also means
the M6 reject cases have only ever asserted "exit code was nonzero" -- the
error text they nominally check has never been observable to the runner.

Add fe_diag_stream(), which resolves once to stdout when FE_DIAG_STDOUT is set
and stderr otherwise, and route diag.c and driver.c through it. The default is
unchanged, so interactive use keeps writing to stderr; the runner sets the
variable in RUN.BAT. The stderr references in check.c and emit_c.c are the
Ferro language's own std.io.stderr writer and are deliberately untouched.

Verified in DOSBox-X: 155 passed. A rejecting compile now records its message,
source excerpt and caret in RESULTS\<key>.LOG.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BScg8CF1sAAM2zVHAu5zvW
2026-08-16 23:09:30 +09:00
coolguyandClaude Opus 5 8b7d6a8d09 dev: make DOS build failures diagnosable
Reviewing an M7 branch took six DOSBox-X runs to find three build blockers
that each take a second to explain. The runner threw away everything needed to
see them.

Capture the compiler build's output. Case commands were redirected to
RESULTS\<key>.LOG but `call BUILD.BAT` was not, so the step that fails first
and blocks every case left only BUILD.FAIL containing the string "FAIL". The
twelve wcl invocations inside it were invisible; finding "Unable to open
src\emit_c_m7.c" meant hand-editing build-dos.bat to add a redirect and
re-running the VM.

Record exit codes. The batch collapsed every outcome to `if errorlevel 1`, so
a compiler that aborted and one that exited 1 with a diagnostic were the same
FAIL. RC.BAT now walks a descending errorlevel ladder into RESULTS\<key>.RC
and the host derives pass/fail from it, which immediately separates an
ordinary rejection (1) from a trap (255). Note the space in `echo 0 >FILE`:
without it DOS parses `0>` as a redirect of handle 0.

Stop falling back to CONSOLE.LOG. That is DOSBox-X's own log -- display
enumeration and INT15 chatter -- so a crashed command reported fifty lines of
emulator noise instead of saying it produced no output.

Add tools/tests/test_dos_names.py. An over-long source name reaches the DOS
build as `Unable to open "src\..."`, which reads as a missing file rather than
a name FAT cannot represent, and only after a VM boot and ten object builds.
The check runs on the host in 0.03s and flags emit_c_m7.c (9-character stem)
on the branch that prompted this.

Also pass -k through to pytest so a single case can be re-run without its
whole milestone, and print the resolved ROOT at startup: an editable install
plus a git worktree will otherwise silently build a different checkout than
the one the shell is in.

Verified on master: 155 passed, unchanged. Recorded codes are 0 for success,
1 for rejections, 255 for the three bounds traps.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BScg8CF1sAAM2zVHAu5zvW
2026-08-16 23:02:28 +09:00
coolguyandClaude Opus 5 5529e3dc14 test: prove --no-checks removes the bounds check
The bounds-no-checks cases emitted and built but never ran, so they only
proved that --no-checks produces compilable C -- not that it removes the
check, which is the entire point of the flag.

A run case could not simply be appended. BOUNDS.FE returns the out-of-bounds
element directly, so with checks removed its exit code is whatever sits past
the array on the stack and there is no correct status to assert. Asserting on
the generated C instead does not work either: emit_c.c defines fe_trap_bounds
unconditionally and --no-checks only suppresses the call sites.

Add NOCHK.FE, which reads one element past a [2]i32 and returns x - x. That
is 0 for whatever garbage the unchecked read produced, so the same source has
a defined outcome both ways: compiled with checks it must trap, compiled with
--no-checks it must run to completion and exit 0. Register both halves and
drop the two BOUNDS-N cases they supersede.

Verified in DOSBox-X: 155 passed, including m3-nochk-trap failing as expected
and m3-nochk-off-run succeeding.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BScg8CF1sAAM2zVHAu5zvW
2026-08-16 22:23:41 +09:00
coolguy 594704a07d dev: promote DOSBox-X and remove QEMU support 2026-08-16 22:14:50 +09:00
coolguyandClaude Opus 5 4ad3e3097b refactor: derive the milestone bounds from the registry
The highest supported milestone was spelled out in six places across four
files: range(1, 7) and default="m6" in test_cli.py, the same pair in
test_milestones_dosboxx.py, and through=6 in both registry.py and suite.py.
Registering M7 meant finding all six, and missing one failed silently.

Derive MAX_MILESTONE and MILESTONES from CASES instead, and move the mN
selector parser to registry.milestone_number so the pytest module stops
carrying its own copy. Adding cases for a new milestone is now enough for
ferro-test to accept --through/--only for it.

No behaviour change: MAX_MILESTONE evaluates to 6, ferro-test still advertises
{m1..m6} with default m6, and the case snapshot is unchanged.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BScg8CF1sAAM2zVHAu5zvW
2026-08-16 22:11:36 +09:00
coolguyandClaude Opus 5 c25312135d refactor: rebuild the milestone registry as a table
registry.py was literally `cat registry_m1_m3.py registry_m4_m6.py`, which
left a duplicate `_c` definition and a stray module-level docstring at the
seam. Replace the hand-rolled append loops with five builders -- _emit, _wcl,
_triple, _rejects, _dump_ast -- and express the cases as one ordered list.

The irregularities are now parameters instead of one-off code, each with the
reason recorded:

- _triple(stem=) for M2 castwhil emitting CAST16
- _triple(build_source=) for M4 prop, which emits PROP.C but compiles
  PROPTEST.C because that file #includes it
- _triple(run_suffix="trap", run_ok=False) for the M3 bounds cases
- _triple(emit_suffix=None) for M4, whose ids lack the -emit suffix
- _emit(output_first=True) for M6, which passes -o before the input

The three scattered 8.3 output-name mappings collapse into one _OUT83 table
keyed by (milestone, name). The key needs both: bad-type is BAD-TY in M2 but
BAD-TYP in M4, and bad-cond is BAD-CO in M2 but unshortened in M5. Values are
carried over verbatim -- the shortenings are inconsistent and several were
never required, but that is a separate decision.

suite.py keeps only Case and drops the all_cases forwarder, so the
registry -> suite -> registry cycle is gone along with the function-scoped
import that worked around it. dosboxx.py still imports Case from suite and is
untouched.

Verified behaviour-preserving by snapshotting (id, milestone, command,
expect_success) for all 150 cases in order before and after: diff is empty.
pytest collects the same 151 items.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BScg8CF1sAAM2zVHAu5zvW
2026-08-16 22:11:13 +09:00
coolguy 0dada80e65 test: unify registry and capture Watcom diagnostics 2026-08-16 21:54:22 +09:00
coolguy 3a7d7de0d3 test: add unified DOSBox-X milestone runner 2026-08-16 21:44:39 +09:00
정시원 aeec10af48 Merge pull request #8 from sebastianrcnt/agent/m7-core-foundation
add M7 semantic and cleanup foundation
2026-08-16 21:20:05 +09:00
정시원 d43f28d06a wire M7 foundation into DOS build 2026-08-16 21:17:57 +09:00
정시원 bc9792532d wire M7 foundation into host build 2026-08-16 21:17:45 +09:00
정시원 47ef8420a9 add optional type kind 2026-08-16 21:17:33 +09:00
정시원 8aae7d9a63 implement cleanup lowering plan 2026-08-16 21:17:15 +09:00
정시원 40ec131ffc add cleanup lowering plan 2026-08-16 21:16:46 +09:00
정시원 c4f3accbb3 implement M7 semantic foundation 2026-08-16 21:16:30 +09:00
정시원 9c3cae7406 add M7 semantic foundation 2026-08-16 21:16:14 +09:00
정시원 43fa9c9bc9 Merge pull request #7 from sebastianrcnt/codex/m6-borrow-checker
Implement M6 borrow checker integration
2026-08-16 20:49:38 +09:00
coolguy aba9370ea6 implement M6 borrow checker integration 2026-08-16 20:46:45 +09:00
정시원 db0ed4bbe0 Merge pull request #6 from sebastianrcnt/agent/m6-ownership-core
implement M6 ownership analysis core
2026-08-16 20:01:32 +09:00
coolguy 748505513d test: audit M6-M9 fixtures for v0.1.8 2026-08-16 20:00:27 +09:00
정시원 3bcf6a33f1 tighten M6 ownership core semantics 2026-08-16 19:59:01 +09:00
정시원 8c4ec8a6e6 complete M6 ownership core primitives 2026-08-16 19:58:18 +09:00
정시원 db2b681f6b implement M6 ownership core 2026-08-16 19:57:15 +09:00
정시원 5981d2b5b1 add M6 ownership core interfaces 2026-08-16 19:56:15 +09:00
정시원 37f092196d Merge pull request #4 from sebastianrcnt/agent/extract-m5-ownership
refactor: extract M5 ownership analysis
2026-08-16 19:50:49 +09:00
정시원 2832888673 Merge pull request #5 from sebastianrcnt/codex/freeze-m6-m9-semantics
freeze M6-M9 semantics and unit model
2026-08-16 19:50:25 +09:00
coolguy 3de0564650 freeze M6-M9 semantics and unit model 2026-08-16 19:48:19 +09:00
정시원 db51611225 route M5 ownership state through own.c 2026-08-16 19:47:19 +09:00
정시원 5c88872ef0 wire ownership helper into DOS build 2026-08-16 19:45:20 +09:00
정시원 accc7dd94a wire ownership helper into compiler build 2026-08-16 19:45:09 +09:00
정시원 89cd035011 extract M5 ownership state helpers 2026-08-16 19:45:02 +09:00
정시원 7fd575859a extract M5 ownership state helpers 2026-08-16 19:44:51 +09:00
정시원 0f67bf3780 revert accidental temp file 2026-08-16 19:21:49 +09:00
정시원 383c97581f noop 2026-08-16 19:21:40 +09:00
정시원 f2e17d265f add M6-M9 specification tests (#3) 2026-08-16 19:08:48 +09:00
coolguy 9986da6f12 chore: isolate Zed clangd from Watcom headers 2026-08-16 19:03:23 +09:00
coolguy d915a7e63c chore: remove obsolete host test scripts 2026-08-16 18:54:23 +09:00
정시원andgithub-actions[bot] 83ce26c209 add minimal Zed syntax highlighting for Ferro (#2)
* add minimal Ferro tree-sitter grammar

* add temporary tree-sitter generation workflow

* generate Ferro tree-sitter parser

* drop custom grammar in favor of Rust grammar reuse

* remove temporary tree-sitter generation workflow

* add Zed extension manifest for Ferro

* configure Ferro files for Zed

* add Ferro syntax highlighting queries

* remove generated custom tree-sitter parser

* remove generated custom tree-sitter node types

* tighten Ferro Zed highlight queries

* add minimal Ferro tree-sitter grammar

* point Zed at Ferro grammar

* refresh Ferro highlights

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-08-16 18:50:19 +09:00
coolguy deafd27939 feat: complete M5 ownership and cleanup 2026-08-16 18:48:35 +09:00
coolguy 351e5dbb23 feat: replace M4 callback writers with safe handles 2026-08-16 18:27:26 +09:00
coolguy 42abc0d7e7 feat: align M3 slices and strings with v0.1.7 2026-08-16 18:23:30 +09:00
coolguy cba2c86fbc fix: reliably answer delayed DOS batch termination prompts 2026-08-16 18:11:52 +09:00
coolguyandClaude Opus 5 ec48a60e3e feat: supervise EXEC with guest liveness instead of a stopwatch
TCPAGENT는 system()이 도는 동안 통째로 얼어 있어 응답도 진행 보고도 못 한다.
그런데 호스트는 소켓에 30초 고정 타임아웃을 걸고, 만료되면 연결 자체를 버렸다.
그래서 35초짜리 컴파일이 "느린 명령"이 아니라 "죽은 에이전트"로 취급됐다.

QEMU는 게스트가 얼어 있어도 계속 돈다. info blockstats의 idle_time_ns로
"작업 중"과 "멈춤"을 구분한다. 실측으로 확인했다: 에이전트가 완전히 벙어리인
동안에도 rd_operations가 7초당 47000씩 증가하고 idle은 0.00s를 유지한다.

- EXEC은 짧은 간격으로 깨어나 감시만 하고 소켓은 절대 안 버린다.
- --idle-timeout(기본 60s)과 --hard-timeout(기본 900s). 후자는 디스크를
  안 쓰는 CPU 바운드 멈춤용 백스톱이다.
- 중단은 QEMU 모니터로 Ctrl+C를 주입하고 COMMAND.COM의
  "Terminate batch file (Y/N/A)?" 프롬프트에 답한다.
- Ctrl+C는 DOS break check에서만 먹는다. FreeDOS 기본값 BREAK=OFF에서
  출력을 파일로 돌린 CPU 바운드 자식은 거기 도달 안 할 수 있다. 그래서
  중단은 보장이 아니라 요청으로 다루고, 명령이 안 멈춰도 RESULT를 끝까지
  수거해 스트림을 깨뜨리지 않는다.
- ferro-vm abort 추가. 실행 중에도 응답해야 하므로 파이프 서버를 요청당
  스레드로 바꿨다.
- 5558 바인딩을 SO_EXCLUSIVEADDRUSE로. Windows의 SO_REUSEADDR는 다른
  프로세스가 같은 포트를 잡아 조용히 반쯤 동작하게 만든다.

검증 (QEMU FreeDOS 실측):
- 32.4초 명령 정상 완료 (이전에는 30초에 실패)
- 실행 중 abort가 0.1초에 응답, exit=95로 종료, 부분 출력 1805B 수거,
  연결 유지
- pause처럼 디스크를 안 쓰는 명령을 idle 15s로 검출해 중단

시리얼 시절에 있다가 TCP 전환에서 사라진 TODO 3건을 복구한다.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012PQm6oAvWX4Lp3iSN5AHGT
2026-08-16 17:42:43 +09:00
coolguy f798a1359f docs: resolve ownership and standard library spec audit 2026-08-16 17:29:45 +09:00
coolguyandClaude Opus 5 8c3dee222e feat: color the agent console and log every command
DOS 콘솔에서 직접 보기 위한 네 가지 수정.

1. 컬러. Open Watcom의 conio.h에는 textattr()이 없고(cprintf/cputs/getch만
   제공) 이 FreeDOS 콘솔은 ANSI 이스케이프도 해석하지 않는다. 그래서 cprintf가
   줄을 배치하게 두고 -- 스크롤을 알아서 처리한다 -- 방금 쓴 셀의 VGA 속성
   바이트만 다시 칠한다. 커서가 그 줄 다음 행의 0열에 있다는 점을 이용해
   스크롤을 직접 추적하지 않고 대상 셀을 찾는다. 줄바꿈된 긴 줄도 처리한다.

2. GET, HASH, LIST, READ, WRITE, QUIT, 미지원 명령을 로깅한다. 이전에는
   EXEC과 PUT만 보였다. PING은 wait-ready가 초당 두 번 폴링하므로 제외한다.
   LIST는 잘림 여부를, PUT은 short write를 구분해 남긴다.

3. put_path가 채워지기만 하고 쓰이지 않아 PUT 완료 줄에 경로가 없었다.
   완료 경로가 둘(길이 0, 본문 수신 완료)이라 put_finished()로 합쳤다.

4. 틱->초 변환이 1.1% 빨랐다. BIOS 틱은 18.2065Hz이므로 delta/18이 아니라
   delta*549/100 (하루치 틱에도 32비트를 넘지 않는다) 을 쓴다.

REBUILD.BAT을 추가한다. BUILD.BAT은 현재 디렉터리에서 wmake만 실행하는데
호스트가 exec으로 부를 때의 시작 디렉터리가 거기가 아니다.

QEMU FreeDOS에서 Open Watcom C++16으로 빌드하고(no warnings, -we 활성)
콘솔 스크린샷으로 색상, 줄바꿈 색칠, 명령별 로그를 확인했다.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012PQm6oAvWX4Lp3iSN5AHGT
2026-08-16 17:13:05 +09:00
coolguyandClaude Opus 5 eff5cbfb12 docs: make the CLI the source of truth for ferro-vm commands
명령 목록이 tools/README.md와 argparse 정의 두 곳에 손으로 동기화되고 있었다.
드리프트가 불가피하므로 목록을 --help로 단일화한다.

cli.py에 서브커맨드별 help/description, 인자 metavar, 예시 epilog를 채웠다.
put의 DOS 8.3 이름 제약처럼 명령에 직접 붙는 함정은 해당 도움말에 넣었다.
tools/README.md는 호스트 요구사항, 셋업, 자동화 구조로 줄이고 목록은 --help로
넘긴다. AGENTS.md에는 CLI가 규범이라는 포인터를 남긴다.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012PQm6oAvWX4Lp3iSN5AHGT
2026-08-16 17:01:30 +09:00
coolguyandClaude Opus 5 2e7502bfa6 chore: ignore stray Windows nul artifact
Git Bash에서 `> nul`을 실행하면 NUL 장치가 아니라 실제 파일이 생긴다. 커밋되면
Windows 체크아웃이 깨지므로 무시하고 기존 흔적을 지운다.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012PQm6oAvWX4Lp3iSN5AHGT
2026-08-16 16:58:42 +09:00
coolguyandClaude Opus 5 c57fa9441d docs: add AGENTS.md and link it from CLAUDE.md
HANDOFF.md 제거로 사라진 VM 빌드 함정(large model, *.obj 링크, -wx -wcd=202,
8.3 파일명, D: 빌드 금지, Ctrl+C 복구)을 되살리고 검증 규칙과 현재 마일스톤
상태를 함께 정리한다. 도구 사용법은 tools/README.md로 링크한다.

CLAUDE.md는 @AGENTS.md 참조만 둔다.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012PQm6oAvWX4Lp3iSN5AHGT
2026-08-16 16:57:03 +09:00
coolguyandClaude Opus 5 f88559c635 wip: extend M5 ownership tests and cleanup emission
조건부 이동, 이중 destroy, 직접 drop 호출에 대한 실패 fixture를 추가하고
runtime harness와 test-dos.bat를 그에 맞춰 갱신한다.

M5는 아직 완료가 아니다. 모든 경로에서 정확히 1회 cleanup, defer/drop의 선언
역순 병합, try 전파 경로 cleanup, MaybeMoved 런타임 live flag, struct drop과
필드 역순 drop, 분기/루프 상태 합류, 누수/이중해제 카운터 harness가 남아 있다.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012PQm6oAvWX4Lp3iSN5AHGT
2026-08-16 16:54:41 +09:00