Repository navigation
fix(cli): create --template uses KB schema fields and defaults (#1598) - #1657
prateeknitcse wants to merge 2 commits into
Conversation
markramm
left a comment
There was a problem hiding this comment.
Thank you for taking #1598. The approach is the one the groom describes: create -k <kb> --template now asks the KB service for the skeleton, using the same declared-fields code (_with_declared_fields) that a real create uses, and refuses undeclared types with the create's own error. The no--k path is unchanged. The tests use the cli_world fixture, which is the right choice. Two things need attention before this can merge: another open PR for the same issue, and a gap between "what the template shows" and "what a create writes".
Blocking
-
Duplicate PR. #1605 (swastiktawate, opened 2026-11-17 12:11Z, about eight hours before this one) also closes #1598. It touches the same files and already has a review with specific requests. Which one lands: #1605 was first, so it keeps #1598 while its author works on it. If #1605 has no answer to its review by 2026-11-20, this PR becomes the one that lands, and #1605 is credited for its approach. In the meantime it is fine to keep this branch ready. The findings below are the same asks #1605 has, so the work is not wasted either way.
-
tests/test_create_template_kb_schema.py: the groom's first acceptance bullet asks that the template be compared with the file a realcreate -k proj -t backlog_item --title xwrites. The test hand-lists a few keys (status,priority,kind,effort,assignee) instead. Please run the real create in the same KB, read the written frontmatter, and assert that the template's keys and defaults equal it (apart fromid,title,tags). A parametrised version over a few (KB, type) pairs is the strongest form; it would also catch the next two points. -
pyrite/services/kb_service.py,template_frontmatter, and--allow-undeclared: with the flag, a skeleton is printed for any type. In a KB withvalidation.enforceon, the real create with the same flag is refused (ruleknown_type), so the template shows a skeleton for a create that fails. Please make the template answer what the create answers, and test it by running both with the same flags. (The review on #1605, item 2, shows the exact reproduction.) -
template_frontmatterand plugin type mappings: the method resolves the type with_resolve_entry_type, which is good, but nothing tests a mapped type (for exampleeventin ajournalism-investigationKB, which a create stores asinvestigation_event). Please add that KB as a test case and check the template'stypeequals the written one.
Non-blocking
entry_commands.py:entry_type = resolved_typeis assigned inside thewithblock but the non--kbranch keeps the old inline skeleton; a short comment saying the two are deliberately separate would help the next reader.- The PR description says tests cover "plugin types" but only
backlog_itemin a software KB is exercised; fine once item 4 is added. - Unknown
-kis already handled bycli_context(it raises the usual KB-not-found error); a one-line test would pin it, since the groom lists it as a regime.
CI: at review time only lock passed and changes was still pending; the test jobs had not started. Please look again once they run. In particular tests/test_production_wiring_guard.py should stay green (your tests do not patch load_config, which is good).
Triggers: touches pyrite/services/kb_service.py (a service shared by CLI, REST and MCP) and changes what a CLI command prints, and there is a competing PR on the same issue. This is the maintainer's merge.
There is a changelog fragment (changelog.d/1598-create-template-kb-schema.fixed.md). No new flag or REST/MCP field is added; MCP and REST have no template call, as the groom notes.
Recommendation: request changes.
…in create --template (pyrite-wiki#1598)
136021e to
22a16a3
Compare
markramm
left a comment
There was a problem hiding this comment.
Thank you for the new head 22a16a3.
Previous items:
- Duplicate PR (#1605): still open and unchanged (#1605 head 1e2af29, last commit 2026-11-17 12:10Z, no author reply since our note). Note stands: #1605 keeps #1598 until 2026-11-20.
- Test does not compare with a real create: not fixed.
tests/test_create_template_kb_schema.py::test_create_template_with_software_kb_matches_create_fields(line ~34-52) still asserts a hand-listed set of keys and never runs a realcreate -k proj -t backlog_item --title x. The name says "matches create" but nothing compares them. --allow-undeclaredparity: not fixed.pyrite/services/kb_service.pytemplate_frontmatterstill skips the refusal wheneverallow_undeclaredis true, with no check ofvalidation.enforce(ruleknown_type) that the real create applies. No test passes--allow-undeclaredto both commands.- Mapped type: not fixed. No test uses a plugin-mapped type (e.g.
eventin ajournalism-investigationKB, stored asinvestigation_event).
The only change since the last review is commit 22a16a3 (a refactor of fence/output handling); it does not touch these items.
New blocking findings: none beyond the items above.
Non-blocking:
pyrite/cli/entry_commands.py(template branch): a one-line comment saying the non--kskeleton is deliberately separate would help the next reader (asked last time, not added).- A one-line test for an unknown
-kwould pin the KB-not-found error.
Recommendation: request changes (items 2..4); #1605 lands #1598 unless it has no answer by 2026-11-20, in which case #1657 lands with #1605 credited.
Closes #1598.
Summary of Changes
pyrite create -k <kb> -t <type> --templatenow resolves the entry type against the specified KB's schema and builds the skeleton with declared fields and defaults (matching the fields and defaults written bycreate).UNDECLARED_TYPE(or undeclared mapping targets), matching the behavior and error of a real create.-k,pyrite create -t <type> --templateretains the standalone core types skeleton.tests/test_create_template_kb_schema.py.changelog.d/1598-create-template-kb-schema.fixed.md.