Repository navigation
Return post-mutation data from store ops; construct the CLI - #1
Merged
Merged
Conversation
Store.Mutate already produced the post-mutation Data, but every operation threw it away and returned only its own result. All three frontends then read the file a second time to recover it, which is where a surprising amount of this codebase came from: - cli.quadrantLabels and mcpserver.labelsOf, two near-duplicate helpers that each did that second read and swallowed its error as "cosmetic" - seven copies of the same closure in the TUI, each ending in store.Load() - a window where the label a command printed came from a later file state than the mutation it was describing Mutating ops now return (result, Data, error). All of the above is deleted. The TUI's mutate reported failure by writing into m.status; two callers sniffed `if m.status == ""` to detect success and three overwrote it unconditionally, so a failed complete, delete, or move printed "done: ..." over its own error while the row stayed on screen. It is now apply(d, err) bool, and success messages are set inside the branch. Input-mode state is set and cleared through enterInput/exitInput, closing a placeholder that leaked from a quadrant rename into the next task edit. The CLI was one 310-line init() mutating a package-level rootCmd, which made flag variables process-global and every RunE unreachable from a test: internal/cli sat at 18.9% coverage with `ike mcp enable|disable` — the consent toggle for agent access — at 0%. Commands are now constructed by newXCmd(open) under NewRootCmd, print to cmd.OutOrStdout(), and share a withStore adapter. openStore, a pure pass-through wrapper, is gone. Coverage: cli 18.9% -> 90.3%, task 81.1% -> 100%, mcpserver 85.9% -> 91.5%, store 85.1% -> 86.1%. 103 tests -> 127. Also folded in, since the above needed them: - taskTool/listTool adapters in mcpserver, replacing eight byte-identical tool bodies - Data.List and Data.ListArchive as the single definitions of each order. The TUI reversed data.Archive instead, which agrees with ListArchive only while every archived task carries a done_at - task.ArchiveRow, so `ike archive` and the TUI archive view cannot drift - time.RFC3339 in place of the layout written out by hand - ops_test.go split into ops/history/labels/mcp, keeping every file under 1000 lines ListArchive keeps make+copy rather than slices.Clone: Clone preserves nil, which made `ike archive --json` emit null instead of []. Pinned by test. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
misspell runs with locale: US, so "signalling" and "cancelling" fail lint. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Store.Mutatealready produced the post-mutationData, but every operation inops.gothrew it away and returned only its own result. All three frontends then read the file a second time to recover it — and a surprising amount of this codebase turned out to be workarounds for that.The change
Mutating ops return
(result, Data, error).Addis(task.Task, Data, error),Undois(string, Data, error). That deletes:cli.quadrantLabelsandmcpserver.labelsOf— two near-duplicate helpers that each did the second read and swallowed its error as "cosmetic"store.Load()SetMCPEnabledis the deliberate exception: nothing renders from it, and handing an MCP-gated caller the whole matrix from the call that flips the gate is a poor shape.The TUI signalled mutation failure through
m.status. Two callers sniffedif m.status == ""to detect success; three overwrote it unconditionally — so a failed complete, delete, or move printeddone: …over its own error while the row stayed on screen. It is nowapply(d, err) bool, and success messages are set inside the branch. Because ops hand back the data, the call sites lost their closures entirely:Input state now goes through
enterInput/exitInput, closing a placeholder that leaked from a quadrant rename into the next task edit, and aneditingIDthat cancel never cleared.The CLI was one 310-line
init()mutating a package-levelrootCmd. Flag variables were process-global, and everyRunEwas unreachable from a test:internal/clisat at 18.9% coverage withike mcp enable|disable— the consent toggle for agent access — at 0%. The store-level gate was well tested; the commands users actually run to grant and revoke access were not tested at all.Commands are now built by
newXCmd(open)underNewRootCmd, print tocmd.OutOrStdout(), and share awithStoreadapter that absorbed 15 copies of open-and-check.openStore, a pure pass-through wrapper, is gone.openstays lazy soike --helpstill works with a brokenIKE_DATA_FILE.Coverage
internal/cliinternal/taskinternal/mcpserverinternal/storeinternal/tui103 tests → 127. New regression tests pin the three status-clobbering bugs, the placeholder leak, the archive ordering contract, and the full
ike mcp enable/disable/statuscycle.Folded in, because the above needed them
taskTool/listTooladapters inmcpserver, replacing eight byte-identical tool bodiesData.List/Data.ListArchiveas the single definition of each order. The TUI reverseddata.Archiveinstead, which agrees withListArchiveonly while every archived task carries adone_attask.ArchiveRow, soike archiveand the TUI archive view cannot drifttime.RFC3339in place of the layout written out by hand, twiceops_test.gosplit intoops/history/labels/mcp— it crossed 1000 lines during this work; nothing in the repo is over it nowOne regression, caught here
Rewriting
ListArchiveI reached forslices.Clone, which preserves nil — soike archive --jsonemittednullinstead of[]on an empty archive. A new test caught it. Reverted tomake+copywith a comment, pinned byTestListArchiveIsNeverNil.Not in scope
Left for follow-ups: the
ToTop/ToBottomsentinels and the two remaining copies of direction parsing; nodupl/funlenbound in.golangci.yml; the sed-based Homebrew tap step inrelease.yml.Verification
gofmtclean ·go vet ./...clean ·go test -race -count=1 ./...passing. No behavior change intended anywhere except the three fixed bugs.🤖 Generated with Claude Code