feat: dogfood cl-prolog/cl-weave with option groups, perf, and hardening#2
Merged
Merged
Conversation
Restore the cl-prolog/cl-weave integration that main had half-migrated (the public parse-argv dispatcher and Prolog-backed option-relation validation were missing, leaving the library and test suite unbuildable), then extend and harden it. 172 tests pass under SBCL. Features (advanced usage / functional requirements): - Prolog rulebase dogfooding for :requires/:conflicts option relations (transitive closure + conflicting-closure detection) in src/option-relations. - exclusive-group / required-exclusive-group: at-most-one and exactly-one option sets, validated through the same conflict machinery and rendered in help as a single "one of: --a | --b" choice instead of pairwise conflicts. Performance: - Drop redundant per-parse declared-relation validation (already done at make-app), memoize transitive-closure Prolog queries, and early-out when no option declares a relation: ~3.9ms -> ~0.006ms per parse in the common case. Security: - Restrict app/command/option names to a safe identifier charset, closing shell-injection vectors in generated bash/zsh/fish completion scripts; also harden the derived completion function name. Bug fixes: - Honor `--` before a command token (POSIX literal separator). - Honor :stop-parsing-p on :flag/:boolean options (long and short forms). - Stop a bare `-` from raising an uncaught array-index error. - Replace the non-transitive option-relation sort comparator (undefined sort behaviour) with a valid strict weak ordering. - Fix LOOP &rest destructuring, prolog atom package instability, and an unbalanced paren in the test helpers. Tests: - cl-weave property-based parser tests (round-trips, `--`/stop-parsing, attached vs separated, multiple-p order, exclusive-group invariants). - consumer-migration Prolog contracts via cl-prolog/weave deftest-queries.
path:../cl-weave and path:../cl-prolog only resolve against a sibling checkout on the local filesystem, so nix flake check has no way to fetch them on a GitHub Actions runner where only cl-cli itself is checked out. Point the inputs at github:takeokunn/cl-weave and github:takeokunn/cl-prolog (the pattern the proven feat/cl-prolog-cl-weave reference branch used) so evaluation and CI actually work.
…ve-integration # Conflicts: # flake.nix
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.
Summary
maincarried a half-migrated cl-prolog/cl-weave integration: the test-sidechanges had landed, but the corresponding
src/side (the publicparse-argvdispatcher and Prolog-backed option-relation validation) wasmissing, leaving the library and test suite unbuildable. This restores the
complete integration and extends it:
src/option-relations.lisp) —:requires/
:conflicts-withoption relations are validated through acl-prologrulebase (transitive closure + conflicting-closure detection) instead of
ad-hoc graph code.
exclusive-group/required-exclusive-group— declare an at-most-oneor exactly-one set of options, validated through the same conflict
machinery and rendered in help as a single "one of:
--a|--b" choiceinstead of pairwise conflicts.
done once at
make-app), memoize transitive-closure Prolog queries, andearly-out when no option declares a relation (~3.9ms → ~0.006ms per parse
in the common case).
identifier charset, closing shell-injection vectors in generated
bash/zsh/fish completion scripts, and harden the derived completion
function name.
--before a command token (POSIX literalseparator), honor
:stop-parsing-pon:flag/:booleanoptions (long andshort forms), stop a bare
-from raising an uncaught array-index error,replace a non-transitive option-relation sort comparator (undefined sort
behaviour) with a valid strict weak ordering, and fix a Prolog atom
package-instability bug plus an unbalanced paren in test helpers.
flake.nixreferencedcl-weave/cl-prologaspath:../cl-weave/path:../cl-prologinputs. Those only resolve against a sibling checkouton the local filesystem; GitHub Actions only checks out
cl-cliitself,so
nix flake checkhad no way to fetch them. Repointed both inputs atgithub:takeokunn/cl-weave/github:takeokunn/cl-prolog(the patternthe earlier working
feat/cl-prolog-cl-weavebranch used) and regeneratedflake.lock.Test plan
sbcl --non-interactive --load tests/run-tests.lisp --eval '(cl-cli/tests:run-tests)' --quit(withCL_WEAVE_SOURCE_DIR/CL_PROLOG_SOURCE_DIRpointed at sibling checkouts) →172 passed, 0 failed, 0 errored.
nix flake lockregenerated cleanly againstgithub:takeokunn/cl-weave/github:takeokunn/cl-prolog.nix eval .#checks.x86_64-linux.sbcl.drvPathand.#devShells.x86_64-linux.default.drvPathresolve without error(full build of the
x86_64-linuxcheck couldn't be exercised on thisdarwin machine — no Linux builder available locally — but evaluation
succeeding confirms the input-fetch fix; CI on
ubuntu-latestbuildsit directly).