Skip to content

Commit 2ca7893

Browse files
hyperpolymathclaude
andcommitted
fix(ci): three foundational unblocks for the main-branch baseline (PR-queue clear)
Every open PR (#357#360) is MERGEABLE/UNSTABLE because main itself has three independent baselines red. Same red shows up on every new PR. Fix each at source so it stops blocking the whole queue. ## 1. `bench/dune` — `Unknown field "alias"` (build + lint) `(test ...)` in dune 3.x does not accept `(alias <name>)` as an inline field. The pattern that works under dune 3.14: (executable ...) ; build the bench runner without auto-@runtest (rule (alias bench) ; only run when explicitly targeted via @bench (action (run ...))) Preserves the visibility-only contract (`just bench` / `dune runtest @bench` still work; normal `dune runtest` no longer pulls bench in). ## 2. Anti-pattern false-positive on `.res` test fixture (governance) `tools/res-to-affine/test/fixtures/sample.res` is the input corpus for the `.res → .affine` migration tool (#57). The estate ban on `.res` files correctly flags it, but the file is fixture-by-construction. The governance bundle already supports an in-file pragma read from the first 8 lines — add `// hypatia:ignore cicd_rules/banned_language_file` to the fixture header so the exemption travels with the file rather than living in a side-channel `.hypatia-ignore` list. ## 3. npm 404 on `@hyperpolymath/affine-vscode` (vscode-smoke) The adapter package is gated on owner action #104 (org create + NPM_TOKEN + `affine-vscode-v0.1.0` tag push) and has not landed. Until then `npm install` 404s and the smoke harness can't even load the extension. Two layers of fix: - `editors/vscode/package.json`: move `@hyperpolymath/affine-vscode` from `dependencies` → `optionalDependencies` so `npm install` tolerates the 404 instead of erroring out. When the package eventually publishes, real installs pick it up automatically. - `lib/codegen_node.ml`: the `--vscode-extension` codegen was emitting an unconditional `const _makeVscodeBindings = require("...")` at top level. Replace with a defensive `try { } catch (_e) { if code !== MODULE_NOT_FOUND throw }` wrapper plus a guarded `extraImports` that returns `{}` when the adapter is absent. Other require errors (syntax, transitive failure) are still rethrown so real bugs aren't masked. Same patch applied to the already-committed `editors/vscode/out/extension.cjs` so today's CI sees the fix without a compiler rebuild round-trip. This is the upstream fix — any future extension compiled with `--vscode-extension` inherits graceful degradation. activate() / deactivate() resolve cleanly when the adapter is missing; the in-editor smoke harness (#139) verifies activation + command registration + restartLsp cycling, which do not require the binding adapter. Refs #104 (adapter publish remains owner-blocked but no longer load-bearing for CI); Refs #57 (migration assistant); Refs #139 (vscode smoke harness). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 26a73a0 commit 2ca7893

5 files changed

Lines changed: 48 additions & 6 deletions

File tree

bench/dune

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,17 @@
2020
; bench/bench_typecheck.ml typecheck + quantity sweep
2121
; bench/bench_codegen.ml wasm-codegen sweep
2222

23-
(test
23+
; `(test ...)` would auto-register bench_main under @runtest, defeating the
24+
; visibility-only contract. Use `(executable ...)` + a dedicated `(rule
25+
; (alias bench) ...)` so the bench is only invoked when explicitly targeted
26+
; (`dune runtest @bench` / `just bench`). The previous `(alias bench)` field
27+
; on `(test ...)` was rejected by dune 3.x as Unknown field.
28+
29+
(executable
2430
(name bench_main)
2531
(libraries affinescript alcotest unix)
26-
(modules bench_main bench_fixtures bench_lex bench_parse bench_typecheck bench_codegen)
27-
(alias bench))
32+
(modules bench_main bench_fixtures bench_lex bench_parse bench_typecheck bench_codegen))
33+
34+
(rule
35+
(alias bench)
36+
(action (run %{exe:bench_main.exe})))

editors/vscode/out/extension.cjs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,21 @@ exports._freeHandle = _freeHandle;
9898
// Inserted by --vscode-extension (issue #105): auto-generated glue so this
9999
// file is directly loadable as a VS Code extension's `main`. Replaces the
100100
// previously hand-written index.cjs + vendored adapter boilerplate.
101-
const _makeVscodeBindings = require("@hyperpolymath/affine-vscode");
101+
//
102+
// Defensive load (issue #104): the adapter package may not yet be on npm
103+
// when this .cjs is bundled into a smoke harness or distributed before the
104+
// `affine-vscode-v*` publish-tag lands. Treat MODULE_NOT_FOUND as a soft
105+
// failure — extraImports degrades to empty so activate()/deactivate() still
106+
// resolve. Any other require error (syntax, transitive failure) is rethrown
107+
// so real bugs are not masked.
108+
let _makeVscodeBindings = null;
109+
try {
110+
_makeVscodeBindings = require("@hyperpolymath/affine-vscode");
111+
} catch (_e) {
112+
if (_e && _e.code !== "MODULE_NOT_FOUND") throw _e;
113+
}
102114
exports.extraImports = function() {
115+
if (typeof _makeVscodeBindings !== "function") return {};
103116
return _makeVscodeBindings(
104117
require("vscode"),
105118
require("vscode-languageclient/node"),

editors/vscode/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,9 @@
150150
"vsce": "^2.15.0"
151151
},
152152
"dependencies": {
153-
"@hyperpolymath/affine-vscode": "^0.1.0",
154153
"vscode-languageclient": "^9.0.0"
154+
},
155+
"optionalDependencies": {
156+
"@hyperpolymath/affine-vscode": "^0.1.0"
155157
}
156158
}

lib/codegen_node.ml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,21 @@ let vscode_extension_wiring ~(adapter : string) ~(no_lc : bool) : string =
132132
// Inserted by --vscode-extension (issue #105): auto-generated glue so this
133133
// file is directly loadable as a VS Code extension's `main`. Replaces the
134134
// previously hand-written index.cjs + vendored adapter boilerplate.
135-
const _makeVscodeBindings = require("%s");
135+
//
136+
// Defensive load (issue #104): the adapter package may not yet be on npm
137+
// when this .cjs is bundled into a smoke harness or distributed before the
138+
// `affine-vscode-v*` publish-tag lands. Treat MODULE_NOT_FOUND as a soft
139+
// failure — extraImports degrades to empty so activate()/deactivate() still
140+
// resolve. Any other require error (syntax, transitive failure) is rethrown
141+
// so real bugs are not masked.
142+
let _makeVscodeBindings = null;
143+
try {
144+
_makeVscodeBindings = require("%s");
145+
} catch (_e) {
146+
if (_e && _e.code !== "MODULE_NOT_FOUND") throw _e;
147+
}
136148
exports.extraImports = function() {
149+
if (typeof _makeVscodeBindings !== "function") return {};
137150
return _makeVscodeBindings(
138151
require("vscode"),
139152
%s,

tools/res-to-affine/test/fixtures/sample.res

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
// SPDX-License-Identifier: MIT
2+
// hypatia:ignore cicd_rules/banned_language_file
23
// Synthetic fixture exercising every Phase-1 anti-pattern. Not a real
34
// ReScript program; the scanner is line-based so it doesn't care.
5+
// The .res extension is intentional — this fixture is the input to the
6+
// `.res → .affine` migration tool (issue #57); exempted from the banned-
7+
// language policy via the inline pragma above (governance bundle reads
8+
// the first 8 lines for `hypatia:ignore <rule>`).
49

510
open Types
611

0 commit comments

Comments
 (0)