feat(cli): add --show-matrix to print a scenario's appropriateness matrix - #46
Open
dchaudhari7177 wants to merge 1 commit into
Open
dchaudhari7177 wants to merge 1 commit into
dchaudhari7177 wants to merge 1 commit into
Conversation
…trix Authoring or debugging a scenario meant reading scenarios.py to see which flows are forbidden. --show-matrix makes a scenario self-documenting: one row per (attribute, recipient) cell, classified forbidden / appropriate / allowed, with the recipient's role for readability. Display only. The branch returns before AGENTS[...] is called and before score() runs, and a test asserts that rather than assuming it: both score and every entry in the AGENTS registry are monkeypatched to raise, so reaching either fails the test. Honours --scenario (defaulting to the club-reserve scenario), exits 0, and rejects an unknown id through the existing parser.error path. Works with --json for a machine-readable matrix. Stdlib only, no new dependency, no model in the loop. classify_flows() is a pure function over the scenario, so the two renderers share one classification and 'allowed' stays derived from the documented unlisted default rather than restated. 12 tests: a known forbidden cell, a known appropriate cell, an unlisted allowed cell, roles shown, --scenario honoured, unknown id rejected, the read-only guarantee, and a JSON test parametrized over every built-in scenario asserting the cell count is attributes x recipients and that the forbidden/appropriate sets round-trip exactly. 78 passed; ruff check, ruff format --check and mypy src clean. Closes bamdadd#37
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.
Closes #37.
Authoring or debugging a scenario meant reading
scenarios.pyto see which flows are forbidden.--show-matrixmakes a scenario self-documenting:--scenario(defaulting to the club-reserve scenario), exits 0, and rejects an unknown id through the existingparser.errorpath.--jsonfor a machine-readable matrix.classify_flows()is a pure function over the scenario, so both renderers share one classification andallowedstays derived from the documented unlisted default rather than restated in two places.Display-only, asserted rather than assumed
The branch returns before
AGENTS[...]is called and beforescore()runs. Rather than trust the ordering,test_show_matrix_runs_no_agent_and_computes_no_scoremonkeypatches bothscoreand every entry in theAGENTSregistry to raise, so reaching either one fails the test instead of quietly working.Tests
12 in
tests/test_show_matrix.py: a known forbidden cell, a known appropriate cell, an unlisted allowed cell, roles shown,--scenariohonoured, unknown id rejected, the read-only guarantee above, and a JSON test parametrized over every built-in scenario asserting the cell count is exactlyattributes x recipientsand that the forbidden/appropriate sets round-trip against the scenario definition.78 passed;
ruff check,ruff format --checkandmypy srcclean.