Repository navigation
fix(rules): check every generated rule before writing the first - #632
Conversation
|
@claude /review |
|
Claude finished @theCodeDrift's task in 1m 53s —— View job Review completeReview mode: incremental — read 0 prior review thread(s) before reviewing.
Assessment: looks correct. I traced the bug this closes — before this PR,
Nothing here warrants an inline comment — I didn't find a correctness, security, or test-coverage gap worth flagging. One thing I'd call out as not a finding but worth confirming matches your intent: the stated out-of-scope gap (an IO failure mid-write after all rules pass their checks can still leave earlier rules written, since the write loop itself isn't transactional) is accurately documented in both the |
Thanks, no findings to act on. The mid-write IO gap is a deliberate boundary, out of scope per #623, and documented in the — AI Coding Agent |
ddf6b2e to
489842f
Compare
Stack (root → tip):
A rule-generation request can produce several rules.
deliverRevisionsverified every rule's signatures up front, but the other pre-write checks (rule id, known engine, andassessDelivery: unsafe paths, case-folded duplicates, incomplete sets) ran inside the write loop. So when rule 2 was refused, rule 1 was already in.taskless/rules/while the command failed and reported no rules. Under--jsonthose refusals also surfaced asINTERNAL_ERROR.What changed
writeServedRuleis split intoprepareServedRule(every check, no filesystem writes) andwritePreparedRule(ensureTasklessDirectory, the write, the missing-fixtures and id-collision warnings).writeServedRulestays as prepare + write, sorule restore/rollbackbehave exactly as before, error types included.deliverRevisionsnow verifies and prepares every rule before writing the first. A prepare refusal that is a plainErroris wrapped asRULE_GENERATION_FAILEDthere (not at the source, so restore's reporting is unchanged);RULE_UNSUPPORTEDkeeps its code. Per-rule notices are held and released in request order, so output ordering is unchanged.deliverRevisionsnow states what it guarantees, and names the remaining gap: an IO failure part-way through the writes (out of scope, per the issue).cli-generated-rule-delivery, archived in this PR (21 scenarios before, 23 after).Testing
packages/cli/test/rule-create-multi-rule.test.tsdrives the realrule create --jsonagainst the v2 stub with two rules: second rule with an unknown engine, an unsafe../path, or an incomplete set. Each asserts the error code and that.taskless/rules/(pre-seeded with an older version of rule 1) is byte-identical afterwards. A fourth case checks both rules are written when both pass. The three refusal cases fail against the previousgenerate.ts.pnpm typecheck,pnpm lint,pnpm --filter @taskless/cli test(2970 passed).Fixes #623