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>
47 lines
2.0 KiB
Go
47 lines
2.0 KiB
Go
package mapping
|
|
|
|
import (
|
|
"os/exec"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// The bridge translates values and nothing else: no network, no filesystem, no
|
|
// clock, no configuration. Every one of those is a caller's to supply, which is
|
|
// what lets this package be reasoned about and tested without a Gitea anywhere.
|
|
//
|
|
// Two imports and no more: internal/issue for what an issue is, and
|
|
// internal/wire for the shapes on the other side. wire is allowed precisely
|
|
// because it is inert — shapes and identifiers over the standard library, with
|
|
// a layering test of its own — so naming a payload here costs nothing and
|
|
// reaches nowhere.
|
|
//
|
|
// DIRECT imports, not the dependency walk internal/issue does. The domain
|
|
// reaches os through internal/project and that is the domain's business; what
|
|
// this test is about is what this package itself reaches for. A transport that
|
|
// grew a helper here — or a lookup that quietly opened a config file — is what
|
|
// it catches.
|
|
func TestTheBridgeTranslatesAndNothingElse(t *testing.T) {
|
|
forbidden := map[string]string{
|
|
"net/http": "an HTTP call belongs in the transport",
|
|
"net": "an HTTP call belongs in the transport",
|
|
"os": "a pure function reads no file and no environment",
|
|
"os/exec": "nothing here shells out",
|
|
"io/ioutil": "a pure function reads no file",
|
|
"time": "the clock is the caller's; a timestamp arrives as a string",
|
|
"git.noodles.cam/claude-skills/marketplace/cli/internal/gitea": "the transport imports this package, never the reverse",
|
|
"git.noodles.cam/claude-skills/marketplace/cli/internal/config": "credentials and repositories are the transport's",
|
|
"git.noodles.cam/claude-skills/marketplace/cli/internal/project": "nothing here resolves a path",
|
|
}
|
|
|
|
out, err := exec.Command("go", "list", "-f", `{{join .Imports "\n"}}`, ".").Output()
|
|
if err != nil {
|
|
t.Fatalf("go list: %v", err)
|
|
}
|
|
for _, dep := range strings.Fields(string(out)) {
|
|
if why, bad := forbidden[dep]; bad {
|
|
t.Errorf("mapping imports %s — %s", dep, why)
|
|
}
|
|
}
|
|
}
|