# Changelog

All notable changes to this project will be documented in this file.

## [0.5.7] - 2026-11-27

### Fixed

- **CI 覆盖率门槛红灯**：`moon coverage report -f full_summary` 把 `playground/playground.mbt`（0/201，演示层，不被单元测试直接调用）计入 core 分母，CI 得到 `core: 593/838 = 70.8%` 判红。`scripts/check_coverage.mjs` 排除 `playground` 与 `_build` 后为 `593/637 = 93.1%`，与本地同口径一致。
- **页面与文档口径漂移**：`docs/index.html` 仍写 92.9%（576/620）与变异 10/10（实测 12/12），而 README 徽章已是 93.1%。页面、评估文档、README 统一到 `593/637 = 93.1%` 与 `12/12`。

### Added

- `scripts/version_points.mjs`：9 个版本引用点的唯一清单（moon.mod / CHANGELOG / README 徽章 / 页面品牌版本与安装命令 / playground `astrolabe_version` / AGENTS / architecture / security）。
- `scripts/check_version.mjs`：版本一致性门禁（9 点必须同版，不一致即退出 1）。
- `scripts/bump_version.mjs`：一次改完 9 点并在 CHANGELOG 补条目骨架，消除"升版漏改 playground 源码常量"这一类必然踩的坑。
- `scripts/sync_pages.mjs --check`：README 徽章 / 页面 / assessment 的数字必须等于 `docs/coverage.json` 真值。
- `docs/coverage.json`：测试数、覆盖率、变异点数、证明目标数的唯一真值文件。
- `scripts/check_release_ready.mjs`：一条命令跑完 9 项发布前门禁（`--skip-slow` 快跑约 1 分钟）。
- `scripts/publish.ps1`：单模块发布脚本（`moon update` → dry-run → publish，按 `Server status` 判定成败）。
- `docs/release.md`：发布流程、真值表、失败分类与三条实测教训（必须 update / 退出码不可信 / PowerShell 5.1 输出捕获）。

### Changed

- `scripts/check_pages.mjs`：删除硬编码的 `version === 0.5.6`、`92.9%`、`10 / 10` 断言，改为读 `moon.mod` 与 `docs/coverage.json`，升版本不再必然报红。

## [0.5.6] - 2026-11-24

### Added

- **`Parser::parse_prefix`**：返回 `(值, 未消费尾部)`，增量/流式解析入口。
- **`Pos::to_string`**：稳定格式 `line:column@offset`（与错误信息一致）。
- **`ParseError::expected_joined`**：期望集合去重保序合并，空集合为 `unknown`。
- **`playground/`**：11 个非 raise 浏览器导出（char/string/range/identifier/int/csv/三入口/错误上下文/commit-vs-alt/位置追踪/版本）。
- **GitHub Pages 库首页**：`docs/index.html` + `style.css` + `app.js`（Hero 错误上下文、12 能力卡、9 演示卡、深浅主题、移动端抽屉导航）。
- **`scripts/check_pages.mjs`**（结构与语义双轨）与 **`scripts/serve_pages.mjs`**。
- **`docs/architecture.md`** 与 **`docs/security.md`**（补齐立项文档面）。

### Changed

- 测试 236 → **239**（四后端各 239/239）；README/评估口径同步。

### Quality

- 页面门禁 **128 项 PASS**（结构 + 导出语义 + 口径）；CDP E2E **28 项**（本地/线上）。
- 覆盖率 92.9%（576/620）与变异 10/10 口径不变；mutation 新增 2 点（expected_joined 去重 / parse_prefix 尾部）→ **12/12**。

## [0.5.5] - 2026-11-20

### Added
- 覆盖率补强：测试 200 → **236**（core / branch / sequence / chain / parser_like 未覆盖分支）
- `scripts/check_coverage.mjs`：覆盖率门槛（core ≥ 90%，库口径 ≥ 85%；排除 benchmarks/examples/cmd/proof）
- `scripts/mutation_test.mjs`：10 变异点（char / core / branch / sequence / chain / parser_like / facade）
- CI 重构：quality（fmt / check / `.mbti` 严格 / docs）/ test × 4 后端 / coverage / prove（Z3）/ examples / 手动 mutation
- `docs/assessment.md` 与 README 口径按实测重写（测试数 / 覆盖率 / 证明 / CI 状态）

### Fixed
- 文档漂移：测试数 178 / 190 / 200 三种说法统一为 **236**；形式化 7 goals；CI 门禁状态与实测对齐

### Verified
- 236 测试 × 4 后端全绿；`moon check --deny-warn --target all` 零警告
- core 覆盖率 **92.9%**（576/620）；`moon prove` **7 goals proved**
- `node scripts/check_coverage.mjs` / `node scripts/mutation_test.mjs` 一键复现

## [0.5.4] - 2026-11-16

### Fixed
- `moon fmt` compliance — 9 个文件格式对齐 moon formatter 标准（doc comment 换行 / 长参数列表折行 / ini_wbtest try/catch 简化）
- CI 补充 `moon fmt --check` 门禁（ci.yml）

### Changed
- `docs/proposal.md` 测试数 190→200、基准数 25→26，与实测对齐
- 根目录 `hackathon2026_astrolabe_proposal.md` 标注过时并重定向至 `docs/proposal.md`（消除仓库内许可证 Apache-2.0 过时信息）

## [0.5.3] - 2026-11-13

### Fixed
- ini_wbtest many 防护测试：match 改用 `ParseResult` 的 `Success(value, state)` 双参构造（原 `Ok/Err` 与 astrolabe 自定义 enum 不匹配——4014/4080 编译错误根因）

### Added
- README「生态采用」节：同作者生态互链（walkzzz MoonBit 工具集三库组合：astrolabe + moon2dart + image）

## [0.5.2] - 2026-11-13

### Added
- README「生态采用」节（中英）：`examples/ini` 依赖示范（INI→JSON 全链路）+ 社区项目征集
- proposal 刷新：本期贡献表 8→13 行（补错误聚合 v0.4.0 / ParserLike v0.5.0 / Show / pitfall-catalog / 记分卡 / check_docs / ini 依赖示范 / 0.5.0 发布记录），第六节已交付/拟实现更新，第十节 INI 提前落地标注

### Changed
- 版本顺移：0.5.1 已发布后的文档/工具增量并入 0.5.2

## [0.5.1] - 2026-11-13

### Added
- `ParseError` implements `Show`（delegates to `format()`）— `inspect` snapshots, `"\{err}"` interpolation and `println` work out of the box
- `docs/pitfall-catalog.md` — 15 measured pitfalls（M 系列 MoonBit 语法演进 9 条 + S 系列解析器语义 6 条，含序列承诺传染 / label 抹掉 alt 多候选 / furthest 位置 / facade 显式列表）
- `docs/assessment.md` 验收记分卡 — 14 检查点逐条 evidence（三口径：没跑过≠通过 / 分母不猜 / 第三方可复算）
- `scripts/check_docs.mjs` — 文档数字一致性自检（4 正向断言 + 5 负向自测全绿；**首跑即检出 badge 190≠196 真实漂移**）

### Changed
- README 快速开始现代化：6 处弃用的 `inspect!` 语法 → `match/println` 风格（同时展示 `e.format()` 错误报告）；`Ok('a')` 快照断言按实测修正为 `Ok(a)`
- README 文档表补全 proposal / assessment / comparison / performance_report / pitfall-catalog（中英双语）
- AGENTS.md 元数据更新（196×4 / mooncakes 0.5.0 已发布）

## [0.5.0] - 2026-11-13

### Added
- `ParserLike` extension-point combinator set (`core/parser_like.mbt`): `pmap` / `pbind` / `palt` / `poption` work over any `(State) -> ParseResult[A]` run-function, so third-party parser types plug into astrolabe combinators by exposing a `run_fn` method; `Parser::run_fn` provided as the standard entry
- Worked extension example `examples/ext` — `Traced[T]`, a logging wrapper parser, with 5 white-box tests demonstrating pmap/pbind/palt/poption integration (190 total × 4 backends)
- Design note: MoonBit traits do not support parameterization separating the implementing type from the result type (`trait ParserLike[A]` is rejected by the parser); the extension point therefore uses the functional convention — the same extension point as `Parser::of`

## [0.4.0] - 2026-11-13

### Added
- `ParseError::merge` — error aggregation with furthest-position-wins semantics; equal positions merge expected labels (deduplicated, order-preserving) and OR the committed flags
- `alt`/`choice` error aggregation — when all branches fail, users see multi-candidate messages ("expected 'a' or 'b'") instead of only the last branch's error
- 7 new tests covering aggregation behavior and alt/choice regression guards (185 total × 4 backends)
- GitHub Actions CI (`.github/workflows/ci.yml`) — `moon check --deny-warn --target all` + `moon test --target all` + `moon bench --target native` gates
- Project proposal `docs/proposal.md` and engineering assessment `docs/assessment.md` (measured data + competitor analysis)

### Changed
- README fully aligned with the actual package layout (core/char/sequence/branch + examples/*), test count updated to 185 × 4 backends, version badge unified
- Formal-verification table and `docs/formal-spec.md` corrected to match `proof/proof.mbt` exactly (EOF correctness replaces the unproven map-flag property)
- Roadmap progress snapshot and vNext competitive roadmap added; benchmark table annotated as historical sample data

## [0.2.0] - 2026-11-13

### Added
- Formal verification package `proof/` — 7 proof functions via MoonBit proof conditions (SMT-backed): commit flag, alt backtrack semantics (P2a/P2b), sequence commit, offset/remaining invariants, EOF correctness
- Benchmark suite `benchmarks/` — 25 benchmarks across basic/compose/control/json/http (`moon bench --target native`)
- Five example packages under `examples/` — uri, json, http, csv_header, calc, with white-box tests
- CLI demo `cmd/main` — interactive showcase for JSON/URI/HTTP parsers

## [0.1.18] - 2026-11-13

### Changed
- README.md 全面重构：emoji 装饰、双语中/英默认中文可切换、`<details>` 折叠、徽章 `flat-square` 风格
- Tutorial (`docs/tutorial.md`) 双语化：中文在前，English 在后
- 8 个新组合子的文档注释修正为标准双语格式（中文段 → `///|` → 英文段）
- README 版本徽章更新至 0.1.17、测试数更新至 147

## [0.1.17] - 2026-11-13

### Added
- `take_while(pred)` — consume consecutive chars matching predicate, return String (always succeeds)
- `take_while1(pred, label~)` — same but requires at least one match
- `option(p, default)` — try `p`, return `default` on uncommitted failure
- `skip_many(p)` / `skip_many1(p)` — repeat `p` discarding results
- `between(open, p, close)` — match `open` + `p` + `close`, return only `p`'s result
- `not_followed_by(p, label~)` — succeed when `p` fails, without consuming input
- `fix(f)` — fixpoint combinator for recursive grammars
- All 8 new combinators exported via root package facade
- 25 new tests across basic/compose/control packages (147 total, up from 122)

## [0.1.16] - 2026-11-13

### Added
- `suberror ParseError` — ParseError is now a `suberror` (not `struct`), auto-upcasting to `Error`
- Accessor methods: `ParseError::pos()`, `ParseError::expected()`, `ParseError::committed()`, `ParseError::context()`
- `Parser::parse_raise()` / `Parser::parse_full_raise()` — raise-based API for `try...catch` usage
- Facade `parse_raise()` / `parse_full_raise()` in root package
- `#warnings("-result_error_return")` on `Result`-returning parse APIs (intentional data-returning design)

### Changed
- `ParseError` changed from `struct` to `suberror ParseError { ParseError(Pos, Array[String], Bool, String) }`
- `ParseError::format()` and `format_with_input()` rewritten to use pattern matching
- `ParseError::commit()` rewritten to use pattern matching
- `control::label()` constructs `ParseError` via constructor instead of struct literal
- All field accesses (`err.committed`, `err.expected`, etc.) changed to method calls (`err.committed()`, `err.expected()`)

## [0.1.15] - 2026-11-13

### Added
- `#alias(return_, deprecated="Use pure instead")` on `pure` — eliminates separate `return_` function
- `#non_exhaustive` on `Method` enum — forward-compatible for future HTTP methods
- `#inline` on `ParseError::commit()` and 14 facade wrapper functions

### Changed
- `return_` is now an alias (deprecated) for `pure` instead of a separate function
- Manual `impl Show for Method` kept (MoonBit deprecated `derive(Show)`, recommends manual impl)

### Removed
- `return_` function definitions in compose/compose.mbt and astrolabe.mbt (replaced by #alias)

## [0.1.14] - 2026-11-12

### Added
- Bilingual doc comments for proof/proof.mbt (7 verified properties)
- Bilingual doc comments for json/json.mbt internal functions
- Bilingual doc comments for http/http.mbt internal functions
- Comprehensive README.md rewrite with bilingual sections

### Changed
- README.md: updated badge to 0.1.13+, added Features section, commitment propagation table,
  formal verification table, expanded HTTP type methods, MoonBit idioms section

## [0.1.13] - 2026-11-12

### Added
- Bilingual (中文/English) doc comments for all public API:
  - `core/core.mbt`: Pos, State, ParseError, Parser, ParseResult
  - `basic/basic.mbt`: char, string, any_char, take, satisfy, end_of_input, peek, skip, char_range, char_class
  - `compose/compose.mbt`: map, bind, pure, return_, seq2/3/4, many/many1, sep_by/sep_by1, count, many_till
  - `control/control.mbt`: commit, alt, choice, label
  - `http/http.mbt`: Method, Version, RequestLine, Header, Request, Uri, parsers, to_string methods
  - `json/json.mbt`: JValue, stringify, value, parse
  - `astrolabe.mbt`: Root facade re-exports

## [0.1.10] - 2026-11-12

### Added
- Z3 SMT formal verification of core semantics (commit/alt backtracking, sequence commits)
- Formal specification documented in `docs/formal-spec.md`
- Comprehensive documentation suite (API reference, tutorial, migration guide)
- Benchmark suite (25 benchmarks across 5 categories)
- CLI demo + 3 examples (URI, CSV, calculator)

### Changed
- License changed from Apache-2.0 to MIT

## [0.9.0] - 2026-11-12

### Added
- Full documentation: README, API reference, tutorial, migration guide
- CHANGELOG.md and CONTRIBUTING.md

## [0.8.0] - 2026-11-12

### Added
- Benchmark suite (25 benchmarks) across 5 categories:
  - `basic_bench`: char, string, satisfy, take, end_of_input
  - `compose_bench`: map, bind, seq2, many, many1, sep_by1, count
  - `control_bench`: alt, choice, commit, label
  - `json_bench`: JSON scalars, objects (10/50/100), arrays (10/100/1000), nested, mixed
  - `http_bench`: HTTP request, headers, URI
- Run via `moon bench --target native benchmarks/`

## [0.7.0] - 2026-11-12

### Added
- CLI demo (`moon run cmd/main`) with interactive JSON/URI/HTTP/CSV/calc showcase
- Example: URI parser (`examples/uri/`)
- Example: CSV header parser (`examples/csv_header/`)
- Example: Arithmetic calculator (`examples/calc/`)
- `Method::to_string()` in HTTP subpackage

## [0.5.6] - 2026-11-12（历史条目：版本号后复用于 2026-11-24 的立项级增强，见上方 0.5.6 条目）

### Added
- Custom parser extension points via `Parser::of(fn)`
- `char_range(lo, hi)` combinator
- `char_class(pred, label)` combinator
- 5+ custom combinator tests

## [0.5.0] - 2026-11-12

### Added
- HTTP parser subpackage (`@astrolabe/http`):
  - Method, Version, RequestLine, Header, Request, Uri types
  - `parse_request_line()`, `parse_header()`, `parse_headers()`, `parse_request()`
  - `parse_uri()`, `parse_uri_string()`, `parse_request_string()`
- 41 HTTP-specific tests

## [0.4.0] - 2026-11-12

### Added
- JSON parser subpackage (`@astrolabe/json`):
  - `JValue` enum (JNull, JBool, JNum, JStr, JArr, JObj)
  - `parse(input)` and `JValue::stringify()`
  - Full escape sequence support including `\uXXXX`
- 21 JSON-specific tests

## [0.3.0] - 2026-11-12

### Added
- `many`, `many1`, `sep_by`, `sep_by1`, `count` combinators
- `many_till(p, end_)` — repeat until end marker (end not consumed)
- `peek(p)` — look ahead without consuming
- `skip(p)` — run and discard result
- `ParseError::format_with_input(err, input)` — error with context snippet and caret

## [0.2.0] - 2026-11-12

### Added
- `map`, `bind`, `pure`, `return_` combinators
- `seq2`, `seq3`, `seq4` sequence combinators
- `commit`, `alt`, `choice`, `label` control combinators
- Commitment semantics: sequences commit on second-parser failure

## [0.1.0] - 2026-11-12

### Added
- Core types: `Pos`, `State`, `ParseError`, `Parser[T]`, `ParseResult[T]`
- Basic combinators: `char`, `string`, `any_char`, `take`, `satisfy`, `end_of_input`
- Root facade package with `pub fn` re-exports
- 30 tests across 4 backends (wasm, wasm-gc, js, native)

## [0.0.1] - 2026-11-12

### Added
- Initial project scaffold
- Published to mooncakes.io as `walkzzz/astrolabe@0.0.1`
