Skip to content

Rule editor: show unsupported rules read-only and keep them on save - #69

Open
avalyset wants to merge 2 commits into
SimulaMet:mainfrom
avalyset:fix/rule-editor-unsupported
Open

avalyset wants to merge 2 commits into
SimulaMet:mainfrom
avalyset:fix/rule-editor-unsupported

Conversation

@avalyset

Copy link
Copy Markdown
Contributor

Builds on #67; merging #67 first keeps this diff to the editor and its test.

renderCustom in templates/partials/agentic_rules_editor.html reads rule.select.kind, which the unsupported rules kept by migration 0004 ({"type": "check", "check": "unsupported", "legacy": {...}}) do not have. With such a rule stored, render() throws a TypeError: no card after it is drawn, and sync() at the end of render() never runs, so a rule added with "+ Add rule" never reaches agentic_rules_json and is lost on save.
This draws an unsupported rule as a read-only card: the reason, worded as rule_engine.unsupported_text words it, the stored legacy object, and a Remove button. The rule stays in the list unchanged and is saved as it was.
The repo has no JavaScript test harness, so the editor change was checked by hand in a browser on the rendered partial with one unsupported and one ordinary rule. Before the change: a TypeError in the console, no cards, and after "+ Add rule" the stored JSON still held 2 rules. After the change: no errors, both cards drawn, "+ Add rule" gives 3 stored rules with the unsupported one unchanged, and Remove works. The new test in infra/tests/test_rules_form.py covers the save path the editor feeds: an unsupported rule and an ordinary one posted together are saved unchanged.
pytest -n 4 -m "not embedded_hatchet" (no API keys in the environment, the local-Ollama live test deselected) gave 1380 passed, 2 skipped on #67 and 1381 passed, 2 skipped with the change; ruff check . is clean.

AI disclosure: implemented with Claude Code.

Migration 0004 keeps rules that need order or grouping as
{"type": "check", "check": "unsupported", "legacy": {...}} and says
the engine reports them as INCONCLUSIVE. validate_rules rejected that
shape, so validate_agentic_metadata raised for every such revision: the
agentic evaluation ended in ERROR and the scenario could not be saved.
Skip validation for exactly that shape.
renderCustom read rule.select.kind, which the unsupported rules kept by
migration 0004 do not have. render() threw on them, so no card after the
rule was drawn and sync() never ran: a rule added afterwards never reached
agentic_rules_json and was lost on save. Draw an unsupported rule as a
read-only card with the reason and a Remove button, and leave it in the
rule list unchanged.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant