Skip to content

Commit 23c3f28

Browse files
committed
fix: remove core/ allowlist, migrate last 2 types, fix cascading
Removed builder.go and types.go from TestCoreStructure allowlist. Moved sync/core Action to validate/ and watch/core ContextUpdate to apply/. Created builder/doc.go. Renamed stuttery functions: DetectBuilder→Detect, FindBuilder→Find, BuilderNames→Names. Deleted dead entity/claude.go and entity.IndexEntryBlock. Zero allowlists remain across all 37 tests. Signed-off-by: Jose Alekhinne <jose@ctx.ist>
1 parent e5e7c5c commit 23c3f28

16 files changed

Lines changed: 128 additions & 117 deletions

File tree

internal/audit/core_structure_test.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,8 @@ import (
1515

1616
// allowedCoreFiles lists the files permitted directly
1717
// in a core/ directory (not in subdirectories).
18-
// builder.go: dep/core houses the interface + registry
19-
//
20-
// that imports language subpackages.
21-
//
22-
// types.go: shared types used by multiple subpackages
23-
//
24-
// where moving would create circular imports.
2518
var allowedCoreFiles = map[string]bool{
26-
"doc.go": true,
27-
"builder.go": true,
28-
"types.go": true,
19+
"doc.go": true,
2920
}
3021

3122
// TestCoreStructure ensures core/ directories contain

internal/cli/dep/cmd/root/run.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ package root
99
import (
1010
"strings"
1111

12+
"github.com/ActiveMemory/ctx/internal/cli/dep/core/builder"
1213
"github.com/spf13/cobra"
1314

14-
"github.com/ActiveMemory/ctx/internal/cli/dep/core"
1515
"github.com/ActiveMemory/ctx/internal/cli/dep/core/render"
1616
"github.com/ActiveMemory/ctx/internal/config/fmt"
1717
"github.com/ActiveMemory/ctx/internal/config/token"
@@ -45,22 +45,25 @@ func Run(
4545
return errConfig.UnknownFormat(format, supportedFormats)
4646
}
4747

48-
var builder core.GraphBuilder
48+
var b builder.GraphBuilder
4949
if projType != "" {
50-
builder = core.FindBuilder(projType)
51-
if builder == nil {
52-
names := strings.Join(core.BuilderNames(), token.CommaSpace)
50+
b = builder.Find(projType)
51+
if b == nil {
52+
names := strings.Join(builder.Names(), token.CommaSpace)
5353
return errConfig.UnknownProjectType(projType, names)
5454
}
5555
} else {
56-
builder = core.DetectBuilder()
57-
if builder == nil {
58-
deps.InfoNoProject(cmd, strings.Join(core.BuilderNames(), token.CommaSpace))
56+
b = builder.Detect()
57+
if b == nil {
58+
names := strings.Join(
59+
builder.Names(), token.CommaSpace,
60+
)
61+
deps.InfoNoProject(cmd, names)
5962
return nil
6063
}
6164
}
6265

63-
graph, buildErr := builder.Build(external)
66+
graph, buildErr := b.Build(external)
6467
if buildErr != nil {
6568
return buildErr
6669
}
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// \ Copyright 2026-present Context contributors.
55
// SPDX-License-Identifier: Apache-2.0
66

7-
package core
7+
package builder
88

99
import (
1010
"github.com/ActiveMemory/ctx/internal/cli/dep/core/golang"
@@ -39,12 +39,12 @@ var Builders = []GraphBuilder{
3939
&rust.Builder{},
4040
}
4141

42-
// DetectBuilder returns the first builder whose Detect()
42+
// Detect returns the first builder whose Detect()
4343
// returns true, or nil if no ecosystem is detected.
4444
//
4545
// Returns:
4646
// - GraphBuilder: The detected builder, or nil
47-
func DetectBuilder() GraphBuilder {
47+
func Detect() GraphBuilder {
4848
for _, b := range Builders {
4949
if b.Detect() {
5050
return b
@@ -53,15 +53,15 @@ func DetectBuilder() GraphBuilder {
5353
return nil
5454
}
5555

56-
// FindBuilder returns the builder matching the given name,
56+
// Find returns the builder matching the given name,
5757
// or nil.
5858
//
5959
// Parameters:
6060
// - name: Ecosystem name to find (e.g. "go", "node")
6161
//
6262
// Returns:
6363
// - GraphBuilder: The matching builder, or nil
64-
func FindBuilder(name string) GraphBuilder {
64+
func Find(name string) GraphBuilder {
6565
for _, b := range Builders {
6666
if b.Name() == name {
6767
return b
@@ -70,12 +70,12 @@ func FindBuilder(name string) GraphBuilder {
7070
return nil
7171
}
7272

73-
// BuilderNames returns all registered builder names for
73+
// Names returns all registered builder names for
7474
// help text.
7575
//
7676
// Returns:
7777
// - []string: Ordered list of ecosystem names
78-
func BuilderNames() []string {
78+
func Names() []string {
7979
names := make([]string, len(Builders))
8080
for i, b := range Builders {
8181
names[i] = b.Name()
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// / ctx: https://ctx.ist
2+
// ,'`./ do you remember?
3+
// `.,'\
4+
// \ Copyright 2026-present Context contributors.
5+
// SPDX-License-Identifier: Apache-2.0
6+
7+
// Package builder defines the dependency graph builder
8+
// interface and registry for supported ecosystems.
9+
//
10+
// Each ecosystem (Go, Node, Python, Rust) implements
11+
// the [Builder] interface. [Detect] auto-detects the
12+
// project type; [Find] looks up a builder by name.
13+
package builder

internal/cli/dep/core/deps_test.go

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ import (
1010
"os"
1111
"path/filepath"
1212
"testing"
13+
14+
"github.com/ActiveMemory/ctx/internal/cli/dep/core/builder"
1315
)
1416

15-
func TestDetectBuilder(t *testing.T) {
17+
func TestDetect(t *testing.T) {
1618
orig, getErr := os.Getwd()
1719
if getErr != nil {
1820
t.Fatal(getErr)
@@ -24,9 +26,9 @@ func TestDetectBuilder(t *testing.T) {
2426
if chdirErr := os.Chdir(tmp); chdirErr != nil {
2527
t.Fatal(chdirErr)
2628
}
27-
if b := DetectBuilder(); b != nil {
29+
if b := builder.Detect(); b != nil {
2830
t.Errorf(
29-
"DetectBuilder() = %q in empty dir, want nil",
31+
"Detect() = %q in empty dir, want nil",
3032
b.Name(),
3133
)
3234
}
@@ -39,16 +41,16 @@ func TestDetectBuilder(t *testing.T) {
3941
if writeErr != nil {
4042
t.Fatal(writeErr)
4143
}
42-
if b := DetectBuilder(); b == nil ||
44+
if b := builder.Detect(); b == nil ||
4345
b.Name() != "go" {
4446
t.Errorf(
45-
"DetectBuilder() with go.mod: want 'go', got %v",
47+
"Detect() with go.mod: want 'go', got %v",
4648
b,
4749
)
4850
}
4951
}
5052

51-
func TestDetectBuilder_Node(t *testing.T) {
53+
func TestDetect_Node(t *testing.T) {
5254
orig, getErr := os.Getwd()
5355
if getErr != nil {
5456
t.Fatal(getErr)
@@ -67,16 +69,16 @@ func TestDetectBuilder_Node(t *testing.T) {
6769
if writeErr != nil {
6870
t.Fatal(writeErr)
6971
}
70-
if b := DetectBuilder(); b == nil ||
72+
if b := builder.Detect(); b == nil ||
7173
b.Name() != "node" {
7274
t.Errorf(
73-
"DetectBuilder() with package.json: want 'node', got %v",
75+
"Detect() with package.json: want 'node', got %v",
7476
b,
7577
)
7678
}
7779
}
7880

79-
func TestDetectBuilder_Python(t *testing.T) {
81+
func TestDetect_Python(t *testing.T) {
8082
orig, getErr := os.Getwd()
8183
if getErr != nil {
8284
t.Fatal(getErr)
@@ -95,16 +97,16 @@ func TestDetectBuilder_Python(t *testing.T) {
9597
if writeErr != nil {
9698
t.Fatal(writeErr)
9799
}
98-
if b := DetectBuilder(); b == nil ||
100+
if b := builder.Detect(); b == nil ||
99101
b.Name() != "python" {
100102
t.Errorf(
101-
"DetectBuilder() with requirements.txt: want 'python', got %v",
103+
"Detect() with requirements.txt: want 'python', got %v",
102104
b,
103105
)
104106
}
105107
}
106108

107-
func TestDetectBuilder_Rust(t *testing.T) {
109+
func TestDetect_Rust(t *testing.T) {
108110
orig, getErr := os.Getwd()
109111
if getErr != nil {
110112
t.Fatal(getErr)
@@ -124,16 +126,16 @@ func TestDetectBuilder_Rust(t *testing.T) {
124126
if writeErr != nil {
125127
t.Fatal(writeErr)
126128
}
127-
if b := DetectBuilder(); b == nil ||
129+
if b := builder.Detect(); b == nil ||
128130
b.Name() != "rust" {
129131
t.Errorf(
130-
"DetectBuilder() with Cargo.toml: want 'rust', got %v",
132+
"Detect() with Cargo.toml: want 'rust', got %v",
131133
b,
132134
)
133135
}
134136
}
135137

136-
func TestDetectBuilder_PriorityOrder(t *testing.T) {
138+
func TestDetect_PriorityOrder(t *testing.T) {
137139
orig, getErr := os.Getwd()
138140
if getErr != nil {
139141
t.Fatal(getErr)
@@ -160,37 +162,37 @@ func TestDetectBuilder_PriorityOrder(t *testing.T) {
160162
t.Fatal(writeErr)
161163
}
162164

163-
if b := DetectBuilder(); b == nil ||
165+
if b := builder.Detect(); b == nil ||
164166
b.Name() != "go" {
165167
t.Errorf(
166-
"DetectBuilder() with go.mod+package.json: want 'go', got %v",
168+
"Detect() with go.mod+package.json: want 'go', got %v",
167169
b,
168170
)
169171
}
170172
}
171173

172-
func TestFindBuilder(t *testing.T) {
174+
func TestFind(t *testing.T) {
173175
for _, name := range []string{
174176
"go", "node", "python", "rust",
175177
} {
176-
if b := FindBuilder(name); b == nil {
178+
if b := builder.Find(name); b == nil {
177179
t.Errorf(
178-
"FindBuilder(%q) = nil, want builder", name,
180+
"Find(%q) = nil, want builder", name,
179181
)
180182
}
181183
}
182-
if b := FindBuilder("java"); b != nil {
184+
if b := builder.Find("java"); b != nil {
183185
t.Errorf(
184-
"FindBuilder('java') = %v, want nil", b,
186+
"Find('java') = %v, want nil", b,
185187
)
186188
}
187189
}
188190

189-
func TestBuilderNames(t *testing.T) {
190-
names := BuilderNames()
191+
func TestNames(t *testing.T) {
192+
names := builder.Names()
191193
if len(names) != 4 {
192194
t.Fatalf(
193-
"BuilderNames() returned %d names, want 4",
195+
"Names() returned %d names, want 4",
194196
len(names),
195197
)
196198
}
@@ -200,7 +202,7 @@ func TestBuilderNames(t *testing.T) {
200202
for i, want := range expected {
201203
if names[i] != want {
202204
t.Errorf(
203-
"BuilderNames()[%d] = %q, want %q",
205+
"Names()[%d] = %q, want %q",
204206
i, names[i], want,
205207
)
206208
}

internal/cli/dep/core/doc.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
// Package core contains dependency graph building and rendering
88
// for Go, Node.js, and Rust ecosystems.
99
//
10-
// [DetectBuilder] auto-selects the right builder based on project
11-
// files. [FindBuilder] looks up by name. Each ecosystem has a
10+
// [builder.Detect] auto-selects the right builder based on project
11+
// files. [builder.Find] looks up by name. Each ecosystem has a
1212
// GraphBuilder implementation that produces a directed graph.
1313
// [MermaidID] sanitizes package names for Mermaid diagram syntax.
1414
package core

internal/cli/sync/core/action/action.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
package action
88

99
import (
10-
"github.com/ActiveMemory/ctx/internal/cli/sync/core"
1110
"github.com/ActiveMemory/ctx/internal/cli/sync/core/validate"
1211
"github.com/ActiveMemory/ctx/internal/entity"
1312
)
@@ -25,8 +24,8 @@ import (
2524
//
2625
// Returns:
2726
// - []Action: List of suggested actions to reconcile context with codebase
28-
func Detect(ctx *entity.Context) []core.Action {
29-
var actions []core.Action
27+
func Detect(ctx *entity.Context) []validate.Action {
28+
var actions []validate.Action
3029

3130
// Check for new top-level directories not mentioned in ARCHITECTURE.md
3231
actions = append(actions, validate.CheckNewDirectories(ctx)...)

internal/cli/sync/core/core_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"testing"
1414

1515
"github.com/ActiveMemory/ctx/internal/cli/initialize"
16-
"github.com/ActiveMemory/ctx/internal/cli/sync/core"
1716
"github.com/ActiveMemory/ctx/internal/cli/sync/core/action"
1817
"github.com/ActiveMemory/ctx/internal/cli/sync/core/validate"
1918
"github.com/ActiveMemory/ctx/internal/config/ctx"
@@ -320,7 +319,7 @@ func TestCheckPackageFiles_ArchContainsDependencies(t *testing.T) {
320319
}
321320

322321
func TestAction_Fields(t *testing.T) {
323-
a := core.Action{
322+
a := validate.Action{
324323
Type: "NEW_DIR",
325324
File: ctx.Architecture,
326325
Description: "test description",
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
// \ Copyright 2026-present Context contributors.
55
// SPDX-License-Identifier: Apache-2.0
66

7-
package core
7+
package validate
88

99
// Action represents a suggested sync action.
1010
//
1111
// Fields:
12-
// - Type: Category of action (e.g., "DEPS", "CONFIG", "NEW_DIR")
12+
// - Type: Category of action
13+
// (e.g., "DEPS", "CONFIG", "NEW_DIR")
1314
// - File: Context file that should be updated
1415
// - Description: What was detected that needs attention
1516
// - Suggestion: Recommended action to take

0 commit comments

Comments
 (0)