fix: usage errors for stray flags, named parse failures, duplicate sources, spec-aligned broken links - #33
Merged
Merged
Conversation
…urces, and spec-aligned broken links Four bug reports against v0.4.0, each with a regression test written before the fix. - index, list, graph, show, backlinks, search and init now reject any dash-prefixed argument as a usage error (exit 4, code 400) instead of treating it as a bundle path and failing as I/O (#31). - A markdown file that is not a concept now fails as a validation error that names the file and the reason, with a hint pointing at OKF §11, instead of an anonymous "load bundle <dir>" I/O error. The loader returns a typed ParseError, I/O and internal envelopes fold the wrapped cause into the message, hidden .md files are skipped like hidden directories, and index loads the bundle before writing so it cannot half-index and then miscount (#27). - Two new warning rules: okf/sources/id-duplicate for a repeated sources[].id and okf/sources/footnote-duplicate for a footnote defined twice. Both were invisible to the join rule by construction (#29). - okf/links/broken is a warning, not an error: OKF §6.1 and §11 say consumers must tolerate broken cross-links and must not reject a bundle for them, so they no longer flip valid or the exit code. Footnote scanning now masks fenced code blocks and inline code spans, so prose that shows [^id] as an example is no longer a dangling reference (#26). Closes #26 Closes #27 Closes #29 Closes #31 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DwzDaurgXen8UC19AeN6tU
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DwzDaurgXen8UC19AeN6tU
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.
Fixes the four open bug reports against v0.4.0. Every change has a regression test that was written first and failed before the fix, including a new end-to-end suite in
cmd/okfthat builds the binary and checks JSON envelopes and exit codes.#31 index and list report an unknown flag as an I/O error
Commands that take no flags (
index,list,graph,show,backlinks,init, and the bundle argument ofsearch) now reject any dash-prefixed argument as a usage error: exit 4,code: 400,kind: usage, messageunknown <cmd> flag: --nope. This matches whatvalidateandlintalready did.#27 a markdown file without frontmatter fails the bundle with no filename
bundle.ParseErrorcarrying the bundle-relative path. Filesystem failures stay plain I/O errors..mdfile to carry frontmatter. The message now readsload bundle demo: parse README.md: no YAML frontmatter block found, and the envelope carries a hint pointing at §11.message. The envelope only ever printed the outer message, so any cause that named a file was dropped..mdfiles are skipped the same way hidden directories already are.okf indexloads the bundle before writing. Previously it wrote index files, swallowed the load error, and reportedcount: 0.#29 duplicate sources id and duplicate footnote definition go unreported
Two new warning rules, both listed in
okf schemaoutput and SARIF rule metadata:okf/sources/id-duplicatefor asources[].iddeclared more than onceokf/sources/footnote-duplicatefor a[^label]:defined more than once#26 broken links as ERROR, and footnotes inside code spans
okf/links/brokenis now a warning. Spec §6.1 says consumers MUST tolerate broken links and §11 says a bundle MUST NOT be rejected for them, sovalidand the exit code no longer flip on one. The finding still surfaces for repair. README and exit-code docs updated to match.[^id]as an example is no longer reported as a dangling reference. Masking preserves byte offsets, so line-start detection for definitions is unaffected.Verification
All pass locally. Each issue's repro script was rerun against the built binary and produces the expected envelope and exit code.
Closes #26
Closes #27
Closes #29
Closes #31
Drafted with Claude Code, reviewed and tested locally.
🤖 Generated with Claude Code
https://claude.ai/code/session_01DwzDaurgXen8UC19AeN6tU