Skip to content

Commit 749a26d

Browse files
committed
fix(#169): address adversarial review — fix criticalCode markers, hardcoded remote, shared state, manifest validation
1 parent 4b626e9 commit 749a26d

3 files changed

Lines changed: 34 additions & 45 deletions

File tree

‎.fork-features/manifest.json‎

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"$schema": "https://json-schema.org/draft/2020-12/schema",
32
"version": "1.0.0",
43
"description": "Fork feature manifest for randomm/opencode. Declares all intentional divergences from upstream anomalyco/opencode and how to verify they survive upstream syncs.",
54
"upstream": {
@@ -19,10 +18,7 @@
1918
"packages/opencode/src/tool/check_task.ts",
2019
"packages/opencode/src/tool/check_task.txt"
2120
],
22-
"modifiedFiles": [
23-
"packages/opencode/src/session/index.ts",
24-
"packages/opencode/src/session/prompt.ts"
25-
],
21+
"modifiedFiles": ["packages/opencode/src/session/index.ts", "packages/opencode/src/session/prompt.ts"],
2622
"criticalCode": [
2723
"backgroundTaskResults",
2824
"trackBackgroundTask",
@@ -31,9 +27,7 @@
3127
"TaskTool",
3228
"CheckTaskTool"
3329
],
34-
"tests": [
35-
"packages/opencode/test/tool/check_task.test.ts"
36-
],
30+
"tests": ["packages/opencode/test/tool/check_task.test.ts"],
3731
"upstreamTracking": {
3832
"relatedPRs": ["anomalyco/opencode#7206"],
3933
"relatedIssues": ["anomalyco/opencode#5887"],
@@ -49,23 +43,15 @@
4943
"packages/opencode/src/tool/rg.txt",
5044
"packages/opencode/test/tool/rg.test.ts"
5145
],
52-
"modifiedFiles": [
53-
"packages/opencode/src/tool/registry.ts"
54-
],
46+
"modifiedFiles": ["packages/opencode/src/tool/registry.ts"],
5547
"deletedFiles": [
5648
"packages/opencode/src/tool/glob.ts",
5749
"packages/opencode/src/tool/glob.txt",
5850
"packages/opencode/src/tool/grep.ts",
5951
"packages/opencode/src/tool/grep.txt"
6052
],
61-
"criticalCode": [
62-
"RgTool",
63-
"files_only",
64-
"rg --json"
65-
],
66-
"tests": [
67-
"packages/opencode/test/tool/rg.test.ts"
68-
],
53+
"criticalCode": ["RgTool", "files_only"],
54+
"tests": ["packages/opencode/test/tool/rg.test.ts"],
6955
"upstreamTracking": {
7056
"absorptionSignals": ["RgTool", "ripgrep.*tool", "rg --json"]
7157
}
@@ -78,17 +64,13 @@
7864
"modifiedFiles": [
7965
"packages/opencode/src/provider/provider.ts",
8066
"packages/opencode/src/provider/transform.ts",
81-
"packages/opencode/src/session/compaction.ts"
82-
],
83-
"criticalCode": [
84-
"context-1m-2025-08-07",
85-
"1000000"
86-
],
87-
"tests": [
88-
"packages/opencode/test/session/compaction.test.ts"
67+
"packages/opencode/src/session/compaction.ts",
68+
"packages/opencode/src/plugin/copilot.ts"
8969
],
70+
"criticalCode": ["context-1m-2025-08-07", "Override context limit for Anthropic models with context-1m"],
71+
"tests": ["packages/opencode/test/session/compaction.test.ts"],
9072
"upstreamTracking": {
91-
"absorptionSignals": ["context-1m", "maxContextTokens.*1000000", "1000000.*context"]
73+
"absorptionSignals": ["context-1m-2025-08-07", "context.limit.*1000000"]
9274
}
9375
}
9476
}

‎.fork-features/verify.ts‎

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,28 @@ import fs from "fs"
1919
const manifestPath = path.resolve(import.meta.dir, "manifest.json")
2020
const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf-8"))
2121

22+
// Basic manifest validation
23+
if (!manifest.features || typeof manifest.features !== "object") {
24+
throw new Error("manifest.json missing 'features' object")
25+
}
26+
if (!manifest.upstream?.remote || !manifest.upstream?.branch) {
27+
throw new Error("manifest.json missing 'upstream.remote' or 'upstream.branch'")
28+
}
29+
2230
// Project root is one level up from .fork-features/
2331
const PROJECT_ROOT = path.resolve(import.meta.dir, "..")
2432

2533
// Collect absorption warnings across all features for final summary
26-
const absorptionWarnings: string[] = []
34+
const absorptionWarnings: { feature: string; signal: string; file: string }[] = []
2735

2836
// Filter to active features only
29-
const activeFeatures = Object.entries(manifest.features).filter(([, feat]: [string, any]) => feat.status === "active")
37+
const activeFeatures = Object.entries(manifest.features as Record<string, any>).filter(
38+
([, feat]) => feat.status === "active",
39+
)
3040

3141
// ---------- Per-feature test suites ----------
3242

33-
for (const [featureName, feature] of activeFeatures) {
34-
const feat = feature as any
35-
43+
for (const [featureName, feat] of activeFeatures) {
3644
describe(`Feature: ${featureName}`, () => {
3745
// --- New files must exist ---
3846
if (feat.newFiles?.length) {
@@ -96,7 +104,8 @@ for (const [featureName, feature] of activeFeatures) {
96104
if (feat.upstreamTracking?.absorptionSignals?.length) {
97105
test(`absorption scan (warnings only)`, () => {
98106
// Get files changed upstream since our divergence point
99-
const result = Bun.spawnSync(["git", "diff", "--name-only", "HEAD...anomalyco/dev"], {
107+
const upstreamRef = `${manifest.upstream.remote}/${manifest.upstream.branch}`
108+
const result = Bun.spawnSync(["git", "diff", "--name-only", `HEAD...${upstreamRef}`], {
100109
cwd: PROJECT_ROOT,
101110
stdout: "pipe",
102111
stderr: "pipe",
@@ -146,17 +155,16 @@ for (const [featureName, feature] of activeFeatures) {
146155
}
147156

148157
if (matched) {
149-
const warning = `⚠️ [${featureName}] signal "${signal}" found in upstream file: ${file}`
150-
absorptionWarnings.push(warning)
158+
absorptionWarnings.push({ feature: featureName, signal, file })
151159
}
152160
}
153161
}
154162

155-
// Log per-feature warnings immediately
156-
if (absorptionWarnings.filter((w) => w.includes(`[${featureName}]`)).length > 0) {
163+
const featureWarnings = absorptionWarnings.filter((w) => w.feature === featureName)
164+
if (featureWarnings.length > 0) {
157165
console.log(`\n${"=".repeat(60)}\n⚠️ ABSORPTION DETECTED for ${featureName}\n${"=".repeat(60)}`)
158-
for (const w of absorptionWarnings.filter((w) => w.includes(`[${featureName}]`))) {
159-
console.log(` ${w}`)
166+
for (const w of featureWarnings) {
167+
console.log(` ⚠️ signal "${w.signal}" found in upstream file: ${w.file}`)
160168
}
161169
console.log("=".repeat(60))
162170
}
@@ -177,15 +185,13 @@ describe("Absorption Summary", () => {
177185
console.log(`# ⚠️ ABSORPTION WARNINGS: ${absorptionWarnings.length} signal(s) detected`)
178186
console.log(`${"#".repeat(60)}`)
179187
for (const w of absorptionWarnings) {
180-
console.log(` ${w}`)
188+
console.log(` ⚠️ [${w.feature}] "${w.signal}" in ${w.file}`)
181189
}
182190
console.log(`${"#".repeat(60)}`)
183191
console.log(`\nRun /sync-upstream to review upstream changes before merging.\n`)
184192
} else {
185193
console.log("\n✅ No absorption signals detected. Fork features are safe.\n")
186194
}
187-
188-
// Summary always passes — it's informational
189195
expect(true).toBe(true)
190196
})
191197
})

‎.opencode/command/sync-upstream.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,9 @@ If there are merge conflicts, resolve them using this hierarchy:
9797
- Preserve all `criticalCode` markers from the manifest
9898
- If both sides changed the same function, **STOP and ask the user**
9999
- Never silently drop fork code in these files
100-
4. **All other files** → accept upstream
101-
5. **Unresolvable conflicts** → STOP and ask the user
100+
4. **`.opencode/` directory** → keep ours (fork-specific configuration)
101+
5. **All other files** → accept upstream
102+
6. **Unresolvable conflicts** → STOP and ask the user
102103

103104
After resolving, stage and continue: `git add -A && git merge --continue`
104105

0 commit comments

Comments
 (0)