specbox 6.39.0 → 6.41.0
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/hooks/freeform-fragment.mjs +23 -9
- package/hooks/hooks-history.json +10 -2
- package/hooks/hooks-manifest.json +5 -3
- package/hooks/lib/closing-evidence.mjs +65 -0
- package/hooks/lib/enforcement-policy.mjs +8 -2
- package/hooks/merge-guard.mjs +116 -0
- package/hooks/settings-hooks.json +6 -0
- package/package.json +1 -1
|
@@ -23,6 +23,10 @@
|
|
|
23
23
|
* get_enforcement_impact also get items.json (`board_content`) and the blocks
|
|
24
24
|
* (`events_content`); the `event_line` of skip_enforcement and
|
|
25
25
|
* record_enforcement_event is appended to doc/tracking/enforcement_events.jsonl.
|
|
26
|
+
*
|
|
27
|
+
* UC-12401: complete_uc gets the policy like start_uc (its measure is closing_evidence) and what
|
|
28
|
+
* both return is saved the same way; mark_ac and mark_ac_batch get the git author as `marked_by`,
|
|
29
|
+
* which FreeForm keeps with the verdict and the receipt of each criterion.
|
|
26
30
|
*/
|
|
27
31
|
|
|
28
32
|
import { execFileSync } from 'node:child_process';
|
|
@@ -48,6 +52,11 @@ import {
|
|
|
48
52
|
} from './lib/freeform-fragment.mjs';
|
|
49
53
|
import { readHookInput } from './lib/utils.mjs';
|
|
50
54
|
|
|
55
|
+
/** The tools whose measures read the board's policy and may record a block (UC-12301, UC-12401). */
|
|
56
|
+
const GATE_TOOLS = new Set(['start_uc', 'complete_uc']);
|
|
57
|
+
/** The tools that mark criteria: FreeForm keeps who marked them (UC-12401). */
|
|
58
|
+
const MARK_TOOLS = new Set(['mark_ac', 'mark_ac_batch']);
|
|
59
|
+
|
|
51
60
|
const { event, toolName, toolInput, cwd, payload } = readHookInput();
|
|
52
61
|
const parsed = parseToolName(toolName);
|
|
53
62
|
const isPolicyTool = !!parsed && POLICY_TOOLS.has(parsed.tool);
|
|
@@ -187,19 +196,24 @@ function pre() {
|
|
|
187
196
|
return result;
|
|
188
197
|
});
|
|
189
198
|
const updatedInput = { ...toolInput, items_content: built.itemsContent };
|
|
190
|
-
// UC-12211: start_uc
|
|
191
|
-
if (parsed.tool
|
|
199
|
+
// UC-12211, UC-12401: start_uc and complete_uc check measures of the board's policy.
|
|
200
|
+
if (GATE_TOOLS.has(parsed.tool) && typeof toolInput.policy_content !== 'string' && existsSync(policyPath)) {
|
|
192
201
|
updatedInput.policy_content = readFileSync(policyPath, 'utf-8');
|
|
193
202
|
}
|
|
203
|
+
// UC-12401: who marked each criterion, kept with its verdict and its receipt.
|
|
204
|
+
if (MARK_TOOLS.has(parsed.tool) && !toolInput.marked_by) {
|
|
205
|
+
const author = gitAuthor();
|
|
206
|
+
if (author) updatedInput.marked_by = author.slice(0, 100);
|
|
207
|
+
}
|
|
194
208
|
process.stdout.write(JSON.stringify({ hookSpecificOutput: { hookEventName: 'PreToolUse', updatedInput } }));
|
|
195
209
|
}
|
|
196
210
|
|
|
197
211
|
/**
|
|
198
|
-
* start_uc (UC-12301): a block
|
|
199
|
-
* go where the policy tools write them. Returns the note for the agent, or null.
|
|
212
|
+
* start_uc (UC-12301) and complete_uc (UC-12401): a block they record (`event_line`) and a skip they
|
|
213
|
+
* spend (`policy_content`) go where the policy tools write them. Returns the note for the agent, or null.
|
|
200
214
|
*/
|
|
201
|
-
function
|
|
202
|
-
if (parsed.tool
|
|
215
|
+
function saveGateEnforcement(response) {
|
|
216
|
+
if (!GATE_TOOLS.has(parsed.tool)) return null;
|
|
203
217
|
const saved = [];
|
|
204
218
|
try {
|
|
205
219
|
const lines = (extractField(response, 'event_line') || '').split('\n').filter((l) => l.trim());
|
|
@@ -217,7 +231,7 @@ function saveStartUcEnforcement(response) {
|
|
|
217
231
|
}
|
|
218
232
|
} catch (err) {
|
|
219
233
|
process.stderr.write(
|
|
220
|
-
`SpecBox freeform-fragment: no se pudo guardar lo que devolvió
|
|
234
|
+
`SpecBox freeform-fragment: no se pudo guardar lo que devolvió ${parsed.tool} (${err.message}). ` +
|
|
221
235
|
'Repite la llamada antes de seguir.\n',
|
|
222
236
|
);
|
|
223
237
|
process.exit(2);
|
|
@@ -228,11 +242,11 @@ function saveStartUcEnforcement(response) {
|
|
|
228
242
|
function post() {
|
|
229
243
|
if (!existsSync(pending)) return;
|
|
230
244
|
const response = payload.tool_response;
|
|
231
|
-
const startNote =
|
|
245
|
+
const startNote = saveGateEnforcement(response);
|
|
232
246
|
const content = extractItemsContent(response);
|
|
233
247
|
if (content == null) {
|
|
234
248
|
unlinkSync(pending); // a read, or an error: nothing to merge
|
|
235
|
-
if (startNote) writeHidden(response, startNote); // a start_uc that a measure stopped
|
|
249
|
+
if (startNote) writeHidden(response, startNote); // a start_uc or complete_uc that a measure stopped
|
|
236
250
|
return;
|
|
237
251
|
}
|
|
238
252
|
try {
|
package/hooks/hooks-history.json
CHANGED
|
@@ -178,7 +178,8 @@
|
|
|
178
178
|
"fcb1fc9a1494c1c63870bdec08368bf3c815b1372e220a6311535b0431c86061",
|
|
179
179
|
"c8c507e2bd1bfa11f681a70b0f236bbc0d23447140ee4424a25533669beb17b4",
|
|
180
180
|
"c212b004d384feba728e0ee7e955bfb09fafe39112cad7c530620a1e932d169a",
|
|
181
|
-
"9ab7d65162056498f7c403eff0eb571b914b9d5c70b9bfdcd52b885c7bd20fef"
|
|
181
|
+
"9ab7d65162056498f7c403eff0eb571b914b9d5c70b9bfdcd52b885c7bd20fef",
|
|
182
|
+
"ca2a8fa168b42abc8aea497962d0b183372ebdcc91afd4df493f435188009751"
|
|
182
183
|
],
|
|
183
184
|
"lib/freeform-fragment.mjs": [
|
|
184
185
|
"d30a15b495cf18cad571e8582b4ce943a75aa4ad8efc5fa11e22420b505dad12",
|
|
@@ -190,7 +191,8 @@
|
|
|
190
191
|
],
|
|
191
192
|
"lib/enforcement-policy.mjs": [
|
|
192
193
|
"3fe25cc63c99d8afbc4dac8a34e142c44bd2d594efa89979993a97b8f48fe688",
|
|
193
|
-
"eed32e2ed08206d6ed22e47a0f61fb9230198376b03fab0be7fe3f54b0c2478a"
|
|
194
|
+
"eed32e2ed08206d6ed22e47a0f61fb9230198376b03fab0be7fe3f54b0c2478a",
|
|
195
|
+
"7aa258be02a1f0a284698ac4c91fc3841db326250550ba0832cf9988b10bb2aa"
|
|
194
196
|
],
|
|
195
197
|
"app-docs-fragment.mjs": [
|
|
196
198
|
"65b82476af664547e732ed0966b07f0126a1b85dbb7f71bfef29b7c04d1115c8",
|
|
@@ -218,5 +220,11 @@
|
|
|
218
220
|
"prd-sync-guard.mjs": [
|
|
219
221
|
"0a163f99dd8e03d57ff027de2c7f1dd614811caaf63aae6cae1d2989834244c8",
|
|
220
222
|
"959790ef27c79fc4b1603a53ca0f222dc4276aec91ca096c25a34e21cb1b4e96"
|
|
223
|
+
],
|
|
224
|
+
"lib/closing-evidence.mjs": [
|
|
225
|
+
"eb956a5663a724b2945531cacb2d72f0f7200f17bd420e3e5ec6c1e7bef77f8b"
|
|
226
|
+
],
|
|
227
|
+
"merge-guard.mjs": [
|
|
228
|
+
"69d3100e1134fd430db521670c9dc60eeb20985c0b4feeb33f0b5f5700a36646"
|
|
221
229
|
]
|
|
222
230
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "6.
|
|
2
|
+
"version": "6.41.0",
|
|
3
3
|
"files": {
|
|
4
4
|
"app-docs-fragment.mjs": "4efae124b02c12f87513e48ca6d4f2e96065c05ca6d8c74352592a8edb21695a",
|
|
5
5
|
"app-docs-sync-guard.mjs": "71f09545b57c143b013c2e532366bfdd1e1a2ae49c7644c9e12e2ab5324d03d3",
|
|
@@ -12,11 +12,12 @@
|
|
|
12
12
|
"design-system-gate.mjs": "419018cadb3e0a4fe0def1c423fed7013b76b2f121312acadbc99fc8e30b8ff5",
|
|
13
13
|
"e2e-gate.mjs": "02e239816cb429f76034088a5370f63a08facce01b4ffd52b338a66acf13028d",
|
|
14
14
|
"file-ownership-guard.mjs": "d8a84370766966cce70b76811de9dd150d170a79c4cb7b9e6b120cfad86a6932",
|
|
15
|
-
"freeform-fragment.mjs": "
|
|
15
|
+
"freeform-fragment.mjs": "ca2a8fa168b42abc8aea497962d0b183372ebdcc91afd4df493f435188009751",
|
|
16
16
|
"freeform-path-guard.mjs": "9ded19e96b0738de5aaf43a97eaa1d88ecd3b341efd432c0b32eb312c4bf5e0a",
|
|
17
17
|
"healing-budget-guard.mjs": "c49c6c34f99545e4009ad88ed9f7eef737e35ce39c11a05d41ad8f976ffae09f",
|
|
18
18
|
"implement-checkpoint.mjs": "f3f219779a1ac4108bc3aabcc7311e9135d9c7795c126a2b5d659e743f5a5a64",
|
|
19
19
|
"implement-healing.mjs": "75392f7de628c3d1d88bf882007bd3281cfedaf0b73940999698daa68ff02411",
|
|
20
|
+
"merge-guard.mjs": "69d3100e1134fd430db521670c9dc60eeb20985c0b4feeb33f0b5f5700a36646",
|
|
20
21
|
"no-bypass-guard.mjs": "d7a31ac193edb8dedda2d9d696aa747612f7348ee475e57653ae0813f9b36189",
|
|
21
22
|
"on-session-end.mjs": "fd5b7cf3bf2c419fd4125e21b338c4c849a4daaef21d5e15253caed54965b40c",
|
|
22
23
|
"pipeline-phase-guard.mjs": "761b82c8b0c4884eba54d529e1f726d547003a6efe05425b45a1a0b77b90fe0d",
|
|
@@ -35,11 +36,12 @@
|
|
|
35
36
|
"uc-state-marker.mjs": "7c649407416f3837196c9cf8a0caf44b8aeead7e2da9eda55ee5526972630cb2",
|
|
36
37
|
"lib/app-spec-zones.mjs": "b05b7d9fe747524c7157c8c67979951affa234d771d3bdd038c9b58cc315f174",
|
|
37
38
|
"lib/autopilot.mjs": "317eabaed8dead40f3d55e642b7465a3ba4e884523e0ae7b933e197153fc6f95",
|
|
39
|
+
"lib/closing-evidence.mjs": "eb956a5663a724b2945531cacb2d72f0f7200f17bd420e3e5ec6c1e7bef77f8b",
|
|
38
40
|
"lib/config.mjs": "a4458d02037cbba952a8f2240549859195788307c95b434e6fd9faa1a1591b85",
|
|
39
41
|
"lib/decisiones.mjs": "6bed3bd37320b6d87f4c77fcac27ed55a6b37776d84a0d4eb2d9cab0c474a520",
|
|
40
42
|
"lib/design-gaps.mjs": "d356d695d7afbafdc6fc420ed66603f11aa523be245bbd7a717d141a4a00701e",
|
|
41
43
|
"lib/enforcement-events.mjs": "5fe963aab5f24c2b50c9991f11dbda48440a98f7394e02c823a276ee1bb2d608",
|
|
42
|
-
"lib/enforcement-policy.mjs": "
|
|
44
|
+
"lib/enforcement-policy.mjs": "7aa258be02a1f0a284698ac4c91fc3841db326250550ba0832cf9988b10bb2aa",
|
|
43
45
|
"lib/execution-context.mjs": "953eb7ec86f6893288df4e76c9c63c737c8e8ba4e337271402ce5eaca00330fa",
|
|
44
46
|
"lib/freeform-fragment.mjs": "23be71af8423bf8fa48dc8519734ff2bef084523a33ece555e4f96bb52bc3141",
|
|
45
47
|
"lib/freeform-path.mjs": "9ea85781821ae911873d1dbd13d58811a6c88e50480d2b3b378725ce2872be0c",
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* lib/closing-evidence.mjs — qué criterios de una UC no están demostrados (UC-12401).
|
|
3
|
+
*
|
|
4
|
+
* La misma regla que `closing_evidence_result` de server/coordination/enforcement.py (una prueba
|
|
5
|
+
* compara las dos): un criterio está demostrado si está hecho y tiene al menos un recibo con
|
|
6
|
+
* `passed: true`. Cuentan todos los criterios; una UC sin criterios no tiene nada demostrado. Un
|
|
7
|
+
* criterio cuya evidencia no se conoce (`evidence: null`) cuenta solo por «hecho».
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export const CLOSING_REASONS = {
|
|
11
|
+
not_done: 'sin marcar',
|
|
12
|
+
no_evidence: 'sin evidencia',
|
|
13
|
+
failing_evidence: 'con evidencia que falla',
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/** `{ total, missing: [{ ac_id, reason }], ok }` de los criterios `[{ ac_id, done, evidence }]`. */
|
|
17
|
+
export function closingEvidence(acs) {
|
|
18
|
+
const list = Array.isArray(acs) ? acs : [];
|
|
19
|
+
const missing = [];
|
|
20
|
+
if (list.length === 0) missing.push({ ac_id: null, reason: 'no_criteria' });
|
|
21
|
+
for (const ac of list) {
|
|
22
|
+
const acId = String(ac?.ac_id ?? '?');
|
|
23
|
+
const evidence = ac?.evidence;
|
|
24
|
+
if (!ac?.done) missing.push({ ac_id: acId, reason: 'not_done' });
|
|
25
|
+
else if (evidence === null || evidence === undefined) continue;
|
|
26
|
+
else if (!Array.isArray(evidence) || evidence.length === 0) missing.push({ ac_id: acId, reason: 'no_evidence' });
|
|
27
|
+
else if (!evidence.some((e) => e && typeof e === 'object' && e.passed === true)) {
|
|
28
|
+
missing.push({ ac_id: acId, reason: 'failing_evidence' });
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return { total: list.length, missing, ok: missing.length === 0 };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** El motivo en una frase, como `closing_evidence_reason` del servidor; null si está todo demostrado. */
|
|
35
|
+
export function closingReason(result) {
|
|
36
|
+
if (result.ok) return null;
|
|
37
|
+
if (result.missing.some((m) => m.reason === 'no_criteria')) return 'La UC no tiene criterios: no hay nada demostrado.';
|
|
38
|
+
const detail = result.missing.map((m) => `${m.ac_id} (${CLOSING_REASONS[m.reason] ?? m.reason})`).join(', ');
|
|
39
|
+
return `${result.missing.length} de ${result.total} criterios sin demostrar: ${detail}.`;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** True si la UC empezó antes de que la medida pasara a «block» (UC-12401 AC-06). */
|
|
43
|
+
export function startedBeforeBlock(startedAt, blockSince) {
|
|
44
|
+
const started = Date.parse(startedAt ?? '');
|
|
45
|
+
const since = Date.parse(blockSince ?? '');
|
|
46
|
+
return Number.isFinite(started) && Number.isFinite(since) && started < since;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Los criterios de una UC de items.json de FreeForm, con su evidencia (null si no consta). */
|
|
50
|
+
export function freeformCriteria(items, ucId) {
|
|
51
|
+
const list = Array.isArray(items) ? items : [];
|
|
52
|
+
const uc = list.find((i) => Array.isArray(i?.labels) && i.labels.includes('UC') && i?.meta?.uc_id === ucId);
|
|
53
|
+
if (!uc) return null;
|
|
54
|
+
return list
|
|
55
|
+
.filter((i) => i?.parent_id === uc.id && Array.isArray(i?.labels) && i.labels.includes('AC'))
|
|
56
|
+
.map((i) => {
|
|
57
|
+
const meta = i.meta && typeof i.meta === 'object' ? i.meta : {};
|
|
58
|
+
const known = Array.isArray(meta.evidence) || (meta.verdict && typeof meta.verdict === 'object');
|
|
59
|
+
return {
|
|
60
|
+
ac_id: meta.ac_id || (/^\[(AC-[^\]]+)\]/.exec(String(i.name || ''))?.[1] ?? '?'),
|
|
61
|
+
done: i.state === 'done',
|
|
62
|
+
evidence: known ? (Array.isArray(meta.evidence) ? meta.evidence : []) : null,
|
|
63
|
+
};
|
|
64
|
+
});
|
|
65
|
+
}
|
|
@@ -46,6 +46,7 @@ export function modosDe(raw, backendType) {
|
|
|
46
46
|
const guardadas = raw && typeof raw.measures === 'object' && raw.measures ? raw.measures : {};
|
|
47
47
|
const modos = {};
|
|
48
48
|
const explicitas = [];
|
|
49
|
+
const bloqueaDesde = {};
|
|
49
50
|
for (const [clave, nuevo] of Object.entries(MEASURES)) {
|
|
50
51
|
const entrada = guardadas[clave];
|
|
51
52
|
const guardada = !!entrada && MODES.includes(entrada.mode);
|
|
@@ -54,8 +55,10 @@ export function modosDe(raw, backendType) {
|
|
|
54
55
|
modos[clave] = modo;
|
|
55
56
|
// UC-12215: la puso una persona (no es el valor por defecto del tablero).
|
|
56
57
|
if (guardada && entrada.source !== 'default') explicitas.push(clave);
|
|
58
|
+
// UC-12401: desde cuándo bloquea, para saber si una UC empezó antes de la regla.
|
|
59
|
+
if (modo === 'block' && typeof entrada?.block_since === 'string') bloqueaDesde[clave] = entrada.block_since;
|
|
57
60
|
}
|
|
58
|
-
return { origin, backendType, modos, explicitas };
|
|
61
|
+
return { origin, backendType, modos, explicitas, bloqueaDesde };
|
|
59
62
|
}
|
|
60
63
|
|
|
61
64
|
/** El modo de una medida en una política leída con leerPolitica («warn» si no la conoce). */
|
|
@@ -125,7 +128,10 @@ export async function leerPolitica({
|
|
|
125
128
|
const policy = {
|
|
126
129
|
origin: r.policy.origin,
|
|
127
130
|
measures: Object.fromEntries(
|
|
128
|
-
Object.entries(r.policy.measures || {}).map(([k, v]) => [
|
|
131
|
+
Object.entries(r.policy.measures || {}).map(([k, v]) => [
|
|
132
|
+
k,
|
|
133
|
+
{ mode: v?.mode, source: v?.source, ...(v?.block_since ? { block_since: v.block_since } : {}) },
|
|
134
|
+
]),
|
|
129
135
|
),
|
|
130
136
|
};
|
|
131
137
|
try {
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* merge-guard.mjs — PreToolUse de `gh pr merge`: lo que se fusiona está demostrado (UC-12401).
|
|
4
|
+
*
|
|
5
|
+
* La medida `closing_evidence` de EP-20, antes de fusionar la PR de la UC activa: cada criterio de la
|
|
6
|
+
* UC está hecho y tiene al menos un recibo que pasa (la misma regla que complete_uc, en
|
|
7
|
+
* lib/closing-evidence.mjs). /implement marca los criterios y pasa la UC a revisión antes de fusionar,
|
|
8
|
+
* así que una prueba de aceptación que falla deja su criterio sin recibo que pase y la fusión no sigue.
|
|
9
|
+
*
|
|
10
|
+
* - En «warn» (por defecto) avisa con cada criterio y su motivo, y deja fusionar.
|
|
11
|
+
* - En «block» detiene la fusión y dice cómo seguir.
|
|
12
|
+
* - Una UC anterior a la regla (en el marcador, o empezada antes de que la medida bloqueara) no se
|
|
13
|
+
* detiene: avisa.
|
|
14
|
+
* - Sin datos (sin UC activa, sin red, un backend sin recibos) no detiene nada.
|
|
15
|
+
*
|
|
16
|
+
* Los criterios salen de doc/tracking/items.json en FreeForm y de `get_uc` con la identidad del
|
|
17
|
+
* dispositivo en native. US-124 añade aquí `independent_review` (UC-12402).
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { execFileSync } from 'node:child_process';
|
|
21
|
+
import { isAbsolute, join } from 'node:path';
|
|
22
|
+
import { readHookInput, readJsonFile } from './lib/utils.mjs';
|
|
23
|
+
import { getProjectConfig } from './lib/config.mjs';
|
|
24
|
+
import { blockWith, noteWith } from './lib/output.mjs';
|
|
25
|
+
import { leerPolitica, modoDe } from './lib/enforcement-policy.mjs';
|
|
26
|
+
import { recordCorrectionIfBlocked, recordEnforcementEvent } from './lib/enforcement-events.mjs';
|
|
27
|
+
import { closingEvidence, closingReason, freeformCriteria, startedBeforeBlock } from './lib/closing-evidence.mjs';
|
|
28
|
+
import { cabecerasDelDispositivo, URL_POR_DEFECTO } from './lib/heartbeat-send.mjs';
|
|
29
|
+
import { llamarTool } from './lib/mcp-client.mjs';
|
|
30
|
+
|
|
31
|
+
const MEASURE = 'closing_evidence';
|
|
32
|
+
const { toolInput, cwd } = readHookInput();
|
|
33
|
+
if (!/\bgh\s+pr\s+merge\b/m.test(String(toolInput.command || ''))) process.exit(0);
|
|
34
|
+
|
|
35
|
+
let root = cwd;
|
|
36
|
+
try {
|
|
37
|
+
root = execFileSync('git', ['-C', cwd, 'rev-parse', '--show-toplevel'], {
|
|
38
|
+
encoding: 'utf-8',
|
|
39
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
40
|
+
timeout: 5000,
|
|
41
|
+
}).trim() || cwd;
|
|
42
|
+
} catch {
|
|
43
|
+
// fuera de un repositorio: se usa la carpeta actual
|
|
44
|
+
}
|
|
45
|
+
process.chdir(root);
|
|
46
|
+
const config = getProjectConfig();
|
|
47
|
+
if (!config.isSpecDriven) process.exit(0);
|
|
48
|
+
const marker = readJsonFile('.quality/active_uc.json');
|
|
49
|
+
if (!marker?.uc_id) process.exit(0);
|
|
50
|
+
|
|
51
|
+
const politica = await leerPolitica({
|
|
52
|
+
root,
|
|
53
|
+
backendType: config.backendType,
|
|
54
|
+
boardId: config.boardId,
|
|
55
|
+
trackingDir: config.freeformRoot,
|
|
56
|
+
});
|
|
57
|
+
const mode = modoDe(politica, MEASURE);
|
|
58
|
+
if (mode === 'off') process.exit(0);
|
|
59
|
+
|
|
60
|
+
/** Los criterios de la UC activa con sus recibos, o null si no se pueden leer. */
|
|
61
|
+
async function criterios() {
|
|
62
|
+
if (config.backendType === 'freeform') {
|
|
63
|
+
const dir = config.freeformRoot
|
|
64
|
+
? (isAbsolute(config.freeformRoot) ? config.freeformRoot : join(root, config.freeformRoot))
|
|
65
|
+
: join(root, 'doc', 'tracking');
|
|
66
|
+
return freeformCriteria(readJsonFile(join(dir, 'items.json')), marker.uc_id);
|
|
67
|
+
}
|
|
68
|
+
if (config.backendType !== 'native' || !config.boardId || process.env.SPECBOX_ENFORCEMENT_POLICY === 'off') return null;
|
|
69
|
+
try {
|
|
70
|
+
const url = process.env.SPECBOX_MCP_URL || URL_POR_DEFECTO;
|
|
71
|
+
const cabeceras = await cabecerasDelDispositivo({ ...process.env, CLAUDE_CODE_MCP_SERVER_URL: url });
|
|
72
|
+
if (!cabeceras.Authorization) return null;
|
|
73
|
+
const uc = await llamarTool({
|
|
74
|
+
url,
|
|
75
|
+
cabeceras,
|
|
76
|
+
nombre: 'get_uc',
|
|
77
|
+
args: { board_id: config.boardId, uc_id: marker.uc_id },
|
|
78
|
+
topeMs: 4000,
|
|
79
|
+
});
|
|
80
|
+
if (!Array.isArray(uc?.acceptance_criteria)) return null;
|
|
81
|
+
return uc.acceptance_criteria.map((ac) => ({ ac_id: ac.id, done: !!ac.done, evidence: Array.isArray(ac.evidence) ? ac.evidence : [] }));
|
|
82
|
+
} catch {
|
|
83
|
+
return null; // sin red o con el tablero caído: no se detiene nada
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const acs = await criterios();
|
|
88
|
+
if (acs === null) process.exit(0);
|
|
89
|
+
const result = closingEvidence(acs);
|
|
90
|
+
if (result.ok) {
|
|
91
|
+
await recordCorrectionIfBlocked({ root, config, measure: MEASURE, ucId: marker.uc_id, by: 'merge-guard' });
|
|
92
|
+
process.exit(0);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const reason = `${marker.uc_id}: ${closingReason(result)}`;
|
|
96
|
+
const how = [
|
|
97
|
+
'Marca cada criterio con mark_ac (o mark_ac_batch) y un recibo que pase: una prueba, una captura, un enlace o una nota escrita si se comprobó a mano.',
|
|
98
|
+
'Si una prueba de aceptación falla, corrige el código, vuelve a pasarla y márcala antes de fusionar.',
|
|
99
|
+
];
|
|
100
|
+
const predates =
|
|
101
|
+
(Array.isArray(marker.predates_rule) && marker.predates_rule.includes(MEASURE)) ||
|
|
102
|
+
startedBeforeBlock(marker.started_at, politica.bloqueaDesde?.[MEASURE]);
|
|
103
|
+
|
|
104
|
+
if (mode === 'block' && !predates) {
|
|
105
|
+
await recordEnforcementEvent({ root, config, measure: MEASURE, ucId: marker.uc_id, outcome: 'blocked', by: 'merge-guard' });
|
|
106
|
+
blockWith('SPEC GUARD: la UC tiene criterios sin demostrar', [
|
|
107
|
+
`SpecBox detuvo la fusión por la medida ${MEASURE}. Motivo: ${reason}`,
|
|
108
|
+
...how.map((h) => `Cómo seguir: ${h}`),
|
|
109
|
+
]);
|
|
110
|
+
}
|
|
111
|
+
noteWith('PreToolUse', 'SPEC GUARD: la UC tiene criterios sin demostrar (aviso)', [
|
|
112
|
+
predates
|
|
113
|
+
? `La UC es anterior a la regla ${MEASURE}: la fusión sigue. Motivo: ${reason}`
|
|
114
|
+
: `Medida ${MEASURE} en «warn»: la fusión sigue. Motivo: ${reason}`,
|
|
115
|
+
...how,
|
|
116
|
+
]);
|
|
@@ -144,6 +144,12 @@
|
|
|
144
144
|
"command": "node .claude/hooks/prd-sync-guard.mjs",
|
|
145
145
|
"timeout": 20
|
|
146
146
|
},
|
|
147
|
+
{
|
|
148
|
+
"type": "command",
|
|
149
|
+
"if": "Bash(*gh pr merge*)",
|
|
150
|
+
"command": "node .claude/hooks/merge-guard.mjs",
|
|
151
|
+
"timeout": 20
|
|
152
|
+
},
|
|
147
153
|
{
|
|
148
154
|
"type": "command",
|
|
149
155
|
"if": "Bash(*git commit*)",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "specbox",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.41.0",
|
|
4
4
|
"description": "Conecta este ordenador a SpecBox sin copiar tokens (specbox login, status y logout) y actualiza los hooks del proyecto sin pisar los tuyos (specbox hooks).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|