fix(lanes): revive dead detect rules and stop alias-blind detection badges

Two defects that made the 16-node ship-feature pipeline look like stage
detection was broken:

- stage-detect matched each rule against a JOIN of the tool input's
  identifying fields. An Agent event really carries description + prompt +
  subagent_type, so `^Explore$` (intake) and `^Plan$` (plan) could never
  fire and both nodes shipped inert — the map jumped straight to
  `implementing`. Rules are now tested one field at a time, which also
  stops a rule matching across the seam between two unrelated fields.

- `detectionLeadsDeclaration` (bin/ccam.js) and `detectionLeads`
  (LaneStripCard.tsx) located the declaration with `indexOf(lane.stage)`.
  Most of what the skill declares is an ALIAS (`tests`, `booting`, `ship`,
  `gate-blocked`), which is not a node id, so indexOf answered -1 and every
  detection — however far behind — was badged as leading. Both now use the
  node the server already resolved it onto (`state === "current"`).

server 1346/1346, client 447/447.
This commit is contained in:
2026-08-28 10:05:24 +07:00
parent fd7f57929c
commit 82263a0ab5
6 changed files with 218 additions and 27 deletions
+15 -6
View File
@@ -1742,15 +1742,24 @@ async function cmdLanesLifecycle(action, args) {
*/
/**
* Whether `lane.detected_stage` is strictly ahead of `lane.stage` in the
* pipeline's node order — the same rule `LaneCard.tsx`'s
* `detectionLeadsDeclaration` uses, so the terminal and the browser never
* disagree about which one is the headline. Unmatched ids sort as -1, so an
* unmatched detected stage never outranks a matched declaration.
* pipeline's node order — the same rule `LaneStripCard.tsx`'s `detectionLeads`
* uses, so the terminal and the browser never disagree about which one is the
* headline. Unmatched ids sort as -1, so an unmatched detected stage never
* outranks a matched declaration.
*
* The declaration is located by the node the SERVER resolved it onto (`state
* === "current"`), never by `indexOf(lane.stage)`: a stage declared under an
* ALIAS — which is most of them, ship-feature's skill says `tests`, `booting`,
* `ship`, `gate-blocked` — is not a node id, so indexOf answers -1 and every
* detection, however far behind, reads as leading.
*/
function detectionLeadsDeclaration(l) {
if (!l.detected_stage) return false;
const ids = (l.pipeline_nodes || []).map((n) => n.id);
return ids.indexOf(l.detected_stage) > ids.indexOf(l.stage);
const nodes = l.pipeline_nodes || [];
return (
nodes.findIndex((n) => n.id === l.detected_stage) >
nodes.findIndex((n) => n.state === "current")
);
}
async function cmdLanes() {