9480e48312
The plugin resolved its issue store from `__file__`, which put it inside a versioned plugin cache: issues written from one project were invisible from the next, and `origin: local` files — the only copy of that work by definition — were stranded a version bump at a time. The walk that answers "which directory is the project" was written three times over, and in a linked worktree the three disagreed. Both are runtime failures rather than logic ones, so the fix is a compiled binary: one walk, imported rather than re-derived, and a layering rule the build graph enforces instead of a grep. Seven packages, knowledge flowing one way. `project` answers which directory is the project and depends on nothing. `issue` is the domain — format, taxonomy, validation, checkboxes, dependency graph, the store, eviction — offline, with no tracker in it. `wire` holds the protocol shapes. `gitea` is the transport, `mapping` the bridge, `config` the credentials, `cmd` the command tree. Four tests hold the boundaries, each failing on a real mistake rather than a naming convention. The marker moves to `.kettle/` and the login pin moves out of the harness's settings file into `.kettle/config.yaml`, which pins a login by NAME; the tokens live in one file per machine, mode 0600, outside every working tree. That retires the PreToolUse guard hook entirely — the binary holds its own credentials, so a command running under a login nobody chose is not expressible rather than caught. `kettle init` migrates an older `tmp/issues` or `.tea/issues` store in, as a move: a store left behind at an old path is one somebody edits by accident months later. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
56 lines
1.8 KiB
Go
56 lines
1.8 KiB
Go
package issue
|
|
|
|
import (
|
|
"os/exec"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// The domain must depend on nothing but the standard library and the one
|
|
// package that answers "which directory is the project".
|
|
//
|
|
// In Python this rule was a grep in a document and a habit; here it is a build
|
|
// graph, and the test fails the moment a tracker concept — an HTTP client, a
|
|
// JSON payload, a login — is imported into the layer that must not know a
|
|
// tracker exists.
|
|
func TestDomainDependsOnNothing(t *testing.T) {
|
|
const allowed = "git.noodles.cam/claude-skills/marketplace/cli/internal/project"
|
|
|
|
out, err := exec.Command("go", "list", "-deps", ".").Output()
|
|
if err != nil {
|
|
t.Fatalf("go list: %v", err)
|
|
}
|
|
for _, dep := range strings.Fields(string(out)) {
|
|
if dep == allowed || dep == "git.noodles.cam/claude-skills/marketplace/cli/internal/issue" {
|
|
continue
|
|
}
|
|
// A standard-library import path has no dot in its first element,
|
|
// because it has no domain name in front of it.
|
|
first, _, _ := strings.Cut(dep, "/")
|
|
if strings.Contains(first, ".") {
|
|
t.Errorf("the domain imports %s — a tracker concept in the layer that must not know one exists", dep)
|
|
}
|
|
}
|
|
}
|
|
|
|
// The other half of the same rule: net/http and its friends are standard
|
|
// library, so "no third-party imports" would not catch a transport written by
|
|
// hand. Name them.
|
|
func TestDomainDoesNotReachTheNetworkOrTheShell(t *testing.T) {
|
|
forbidden := []string{"net/http", "net", "os/exec", "encoding/json"}
|
|
|
|
out, err := exec.Command("go", "list", "-deps", ".").Output()
|
|
if err != nil {
|
|
t.Fatalf("go list: %v", err)
|
|
}
|
|
deps := map[string]bool{}
|
|
for _, d := range strings.Fields(string(out)) {
|
|
deps[d] = true
|
|
}
|
|
for _, f := range forbidden {
|
|
if deps[f] {
|
|
t.Errorf("the domain reaches %s — that belongs in the transport", f)
|
|
}
|
|
}
|
|
}
|