candor-ts 0.8.0 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/scan.mjs +10 -4
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "candor-ts",
|
|
3
|
-
"version": "0.8.
|
|
4
|
-
"description": "candor for TypeScript
|
|
3
|
+
"version": "0.8.2",
|
|
4
|
+
"description": "candor for TypeScript \u2014 per-function side effects, transitively, with a policy gate (candor-spec 0.8)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@types/node": "^25.9.2",
|
package/scan.mjs
CHANGED
|
@@ -2090,9 +2090,10 @@ if (policyPath) {
|
|
|
2090
2090
|
const incompleteMap = new Map();
|
|
2091
2091
|
for (const [name, rec] of fns) if (rec.incomplete.size) incompleteMap.set(name, rec.incomplete);
|
|
2092
2092
|
gateViolations = evaluatePolicy(parsePolicy(text), functions, cg, incompleteMap);
|
|
2093
|
-
//
|
|
2094
|
-
// [AS-EFF-…] violation lines to stderr so
|
|
2095
|
-
|
|
2093
|
+
// When stdout carries a JSON document — the §2 envelope (--json) OR the streamed gate verdict
|
|
2094
|
+
// (--gate-json -) — it must stay pure JSON: route the gate's [AS-EFF-…] violation lines to stderr so
|
|
2095
|
+
// a `… | jq` / `… | candor-sarif` pipe never breaks.
|
|
2096
|
+
const emitViolation = (wantJson || gateJsonPath === "-") ? (l) => console.error(l) : (l) => console.log(l);
|
|
2096
2097
|
for (const x of gateViolations) emitViolation(`[${x.rule}] ${x.detail}`);
|
|
2097
2098
|
}
|
|
2098
2099
|
// --gate-json ⟨0.8⟩: the structured gate verdict { spec, ok, violations:[{rule,fn,effects,detail}] }, from
|
|
@@ -2101,7 +2102,12 @@ if (policyPath) {
|
|
|
2101
2102
|
if (gateJsonPath) {
|
|
2102
2103
|
const verdict = JSON.stringify({ spec: SPEC_VERSION, ok: gateViolations.length === 0, violations: gateViolations }, null, 1);
|
|
2103
2104
|
if (gateJsonPath === "-") console.log(verdict);
|
|
2104
|
-
else
|
|
2105
|
+
else {
|
|
2106
|
+
// The verdict is a SURFACING side-output: an unwritable path must be one stderr line, never a raw
|
|
2107
|
+
// ENOENT crash whose exit 1 reads as a policy violation on a clean run (max-review find).
|
|
2108
|
+
try { writeAtomic(gateJsonPath, verdict + "\n"); }
|
|
2109
|
+
catch (e) { console.error(`candor-ts: could not write --gate-json ${gateJsonPath}: ${e.message}`); }
|
|
2110
|
+
}
|
|
2105
2111
|
}
|
|
2106
2112
|
if (policyPath && gateViolations.length) {
|
|
2107
2113
|
console.error(`candor-ts: ${gateViolations.length} policy violation(s)`);
|