Skip to content

chore: remove dead code, fix dream archive status, and update docs - #181

Closed
parlakisik wants to merge 3 commits into
mainfrom
chore/dead-code-cleanup
Closed

parlakisik wants to merge 3 commits into
mainfrom
chore/dead-code-cleanup

Conversation

@parlakisik

Copy link
Copy Markdown
Contributor

Summary

A dead-code sweep over the root module and tools/ctxctl, plus two fixes it surfaced.

How candidates were found: golang.org/x/tools/cmd/deadcode over ./... ./tools/ctxctl/..., with and without -test, intersected across GOOS darwin/linux/windows. 49 functions came up that the shipped binaries never reach (the kb writer stack was excluded on purpose). Each candidate was checked against specs/, .context/TASKS.md, git history, and whether it serves as a test seam. Anything uncertain was kept.

1. chore: remove dead code and update docs

  • Removed: internal/cli/initialize/core/vscode and internal/write/vscode. ctx init never called them; .vscode/mcp.json ships through ctx setup copilot and cline. The text keys and config/vscode constants only they used are also gone.
  • Removed: dream SourceStatusKnown, DecisionKnown, errDream.ReadSource, and the constants only they used.
  • Removed: pad blob.Contains; parse.FormatEntries, replaced earlier by FormatEntriesWithIDs; and store.EnsureGitignore, replaced by project.EnsureGitignoreEntries.
  • Removed: the rc.ArchiveAfterDays() getter. The .ctxrc field stays so existing configs still parse, and it is now documented as inert (docs, schema, .ctxrc.dev).
  • Moved into _test.go: parser.find, parser.registeredTools, and the hooks registry helpers.
  • Kept on purpose:
    • hub cluster-mode scaffold (tasks H-02, H-13, H-14)
    • disclosure invariant checks (pd-m1 plan and compliance test)
    • closeout Write (kb pipeline spec)
    • dream.Backup (backup-before-mutate in the spec)
    • ParseFile
    • the kb writer stack
    • test seams (rc.Reset, SetSink, SetDirForTest, testctx.Declare, and similar)
  • Docs: package doc.go files, docs/ configuration and CLI reference, .context notes. The three site/ pages were regenerated with the pinned zensical 0.0.51; unrelated generator churn was reverted.

2. test(codex): stop deriving paths from env in deploy tests

golangci-lint 2.14's gosec G703 flags os.Getenv-derived paths in deploy_test.go; this already fails on main with 2.14. withTempProjectAndHome now returns the temp $CODEX_HOME, so fixtures use a t.TempDir path.

3. fix(dream): record archived status in state.json on archive

specs/ctx-dream.md requires per-source status to track dispositions, but only active was ever written. An archive moved the idea into ideas/done/ while state.json still said active. The archived source's record now becomes archived. Covered by the new test TestAcceptArchiveMarksSourceArchived.

Test plan

  • go build / go vet on ./... ./tools/ctxctl/... (Go 1.27.1)
  • go test ./... ./tools/ctxctl/...: all packages pass, including TestNoDeadExports
  • golangci-lint 2.14.0: 0 issues
  • shellcheck, lint-drift, lint-docstrings, lint-mixed-funcs, lint-imports (advisory notes only, in untouched files)
  • version, Go version, why-docs, copilot/codex/opencode/pi skills, and steering sync checks
  • deadcode re-run: the only remaining entries are deliberately kept symbols and the kb stack

Remove functions that the shipped ctx and ctxctl binaries never reach
(deadcode, intersected across darwin/linux/windows), after validating
each candidate against specs, open tasks, and test-seam usage.

Removed:
- internal/cli/initialize/core/vscode and internal/write/vscode: never
  wired into ctx init; .vscode/mcp.json ships via setup copilot/cline.
- dream: SourceStatusKnown, DecisionKnown, errDream.ReadSource and the
  vocabulary constants only they used.
- pad: blob.Contains, parse.FormatEntries (superseded by
  FormatEntriesWithIDs), store.EnsureGitignore (superseded by
  project.EnsureGitignoreEntries).
- rc.ArchiveAfterDays getter; the .ctxrc field stays for compatibility
  and is now documented as inert.
- journal/parser find/registeredTools and hooks/messages helpers moved
  into test files.

Kept on purpose: hub cluster-mode scaffold (tasks H-02/H-13/H-14),
disclosure invariant checks, closeout Write, dream.Backup, ParseFile,
the kb writer stack, and test seams.

Docs updated: package doc.go files, docs/ configuration and CLI
reference, regenerated site pages, ctxrc schema, .context notes.

Signed-off-by: Murat Parlakisik <parlakisik@gmail.com>
gosec G703 (golangci-lint 2.14) flags paths built from os.Getenv as
tainted. Add withTempProjectAndHome, which returns the temporary
$CODEX_HOME it sets, and seed fixtures from that t.TempDir path
instead of reading the environment back.

Signed-off-by: Murat Parlakisik <parlakisik@gmail.com>
specs/ctx-dream.md requires per-source status to track dispositions
(active | archived | promoted | merged), but nothing ever wrote
anything except "active". Accepting or amending to an archive action
moved the idea into ideas/done/ while its state.json record stayed
"active".

After the ledger append, mark the archived source's record as
SourceArchived. Sources with no saved record are left untouched.

Signed-off-by: Murat Parlakisik <parlakisik@gmail.com>
@parlakisik parlakisik closed this Oct 3, 2026
@parlakisik
parlakisik deleted the chore/dead-code-cleanup branch October 3, 2026 20:18
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