ECC/tests/lib
Gaurav Dubey 5987bd4dc6
feat(session-start): rank injected instincts by project/stack relevance (#2466)
* feat(session-start): rank injected instincts by project/stack relevance

Instinct selection at SessionStart ranked purely by confidence, so a
high-confidence instinct about an unrelated stack could take an injection
slot from a lower-confidence instinct that is actually relevant to the
current project.

Rank by confidence + location/stack relevance instead: project-scoped
instincts, and instincts whose domain/trigger matches the detected stack
(languages/frameworks via detectProjectType, plus terraform/dbt markers),
get a small additive boost. The confidence>=threshold floor and the
injection cap are unchanged, and ranking degrades to confidence-only when
nothing matches or when ECC_INSTINCT_RELEVANCE_RANKING is set to off.

The ranking helpers live in scripts/lib/instinct-relevance.js with unit
coverage in tests/lib/, plus an end-to-end ordering test in tests/hooks/.

Completes part (b) of #2371; part (a) (configurable count + threshold)
shipped in #2413.

Fixes #2371

* refactor(session-start): drop redundant confidence tiebreaker in instinct sort

Greptile flagged that the secondary `right.confidence` comparison in
summarizeActiveInstincts' sort was dead code when relevance ranking is
disabled and, when enabled, was reached only on a floating-point tie of the
combined score — where it skipped the intended scope-label tiebreaker.

Remove it: the primary combined-score comparison already reduces to
confidence-only ordering when relevance is off, so behavior there is
unchanged; a genuine combined-score tie now falls through to the documented
scope-first, then id, order.

* test: isolate instinct relevance environment

---------

Co-authored-by: haelyra <49814733+haelyra@users.noreply.github.com>
2026-08-10 21:46:24 -04:00
..
helpers test(lib): extract shared mini test runner for coordination tests (#2663) 2026-08-04 00:29:31 -04:00
agent-compress.test.js fix: use scalar Claude agent tools (#2583) 2026-07-26 03:20:15 -07:00
agent-data-home.test.js fix: harden local dashboard and data boundaries (#2585) 2026-07-27 11:11:29 -07:00
agent-proximity.test.js feat(layer4): line-range channel + trigger firing 2026-06-20 17:30:52 -04:00
changed-files-store.test.js fix: port safe ci cleanup from backlog 2026-04-01 16:09:54 -07:00
claude-plugin-setup.test.js feat(install): add guided multi-harness installer (#2649) 2026-08-06 15:39:49 -04:00
claude-scope-migration.test.js feat(install): add guided multi-harness installer (#2649) 2026-08-06 15:39:49 -04:00
codex-plugin-setup.test.js feat(install): add guided multi-harness installer (#2649) 2026-08-06 15:39:49 -04:00
command-plugin-root.test.js fix(commands): probe for auto-update.js in auto-update ECC_ROOT resolver (#2462) 2026-08-04 00:28:59 -04:00
control-pane-actions.test.js feat: add ECC2 local control pane (#2131) 2026-06-03 21:54:30 +08:00
control-pane-message-sink.test.js feat(layer4): live messages-table wiring for proximity triggers 2026-06-20 20:49:17 -04:00
control-pane-proximity.test.js feat(layer4): live messages-table wiring for proximity triggers 2026-06-20 20:49:17 -04:00
control-pane-state.test.js feat(control-pane): add agent+human JIT assignment view to the work-items board 2026-06-18 16:59:30 -04:00
cost-estimate.test.js feat: add ECC statusline observability hooks 2026-05-11 23:44:06 -04:00
dry-run.test.js feat(install): add guided multi-harness installer (#2649) 2026-08-06 15:39:49 -04:00
github-coordination-branches.test.js test(lib): extract shared mini test runner for coordination tests (#2663) 2026-08-04 00:29:31 -04:00
github-coordination-policy.test.js test(lib): extract shared mini test runner for coordination tests (#2663) 2026-08-04 00:29:31 -04:00
github-coordination-store.test.js test(lib): extract shared mini test runner for coordination tests (#2663) 2026-08-04 00:29:31 -04:00
github-coordination.test.js fix: address second round of code-review findings 2026-06-11 14:25:58 -04:00
github-origin.test.js feat(install): add guided multi-harness installer (#2649) 2026-08-06 15:39:49 -04:00
harness-capabilities.test.js feat(install): add guided multi-harness installer (#2649) 2026-08-06 15:39:49 -04:00
inspection.test.js
install-claude-skill-migration.test.js feat(install): add guided multi-harness installer (#2649) 2026-08-06 15:39:49 -04:00
install-config.test.js feat: add install catalog and project config autodetection 2026-03-27 05:56:39 -04:00
install-executor.test.js feat(install): add guided multi-harness installer (#2649) 2026-08-06 15:39:49 -04:00
install-lifecycle.test.js fix: harden local dashboard and data boundaries (#2585) 2026-07-27 11:11:29 -07:00
install-link-rewrite.test.js fix: flatten Claude skill installs (#2582) 2026-07-26 03:20:06 -07:00
install-manifests.test.js fix(install): exclude ECC skills from antigravity install target (#2680) 2026-08-04 16:57:27 -04:00
install-request.test.js fix(installer): harden locale docs install 2026-05-17 20:46:04 -04:00
install-state.test.js fix: harden release surface version and packaging sync (#1388) 2026-04-12 22:33:32 -07:00
install-targets.test.js feat(install): add guided multi-harness installer (#2649) 2026-08-06 15:39:49 -04:00
instinct-relevance.test.js feat(session-start): rank injected instincts by project/stack relevance (#2466) 2026-08-10 21:46:24 -04:00
llm-summary.test.js fix(tests): use mkdtempSync for test scratch dirs (CodeQL js/insecure-temporary-file) (#2443) 2026-07-04 13:44:27 -07:00
locale-install.test.js fix: flatten Claude skill installs (#2582) 2026-07-26 03:20:06 -07:00
loopback-guard.test.js fix: harden local dashboard and data boundaries (#2585) 2026-07-27 11:11:29 -07:00
mcp-config.test.js feat: support disabling bundled mcp servers 2026-04-05 14:37:28 -07:00
mcp-inventory.test.js feat: MCP inventory (ecc.mcp.v1) — unified cross-harness MCP config view (#2146) 2026-06-06 03:55:17 +08:00
memory-schema.test.js feat: add cross-harness memory vault (#2581) 2026-07-26 02:46:59 -07:00
memory-vault.test.js fix(memory-vault): compare dev only when both stats report one (#2637) 2026-08-08 17:06:18 -04:00
multi-harness-setup.test.js feat(install): add guided multi-harness installer (#2649) 2026-08-06 15:39:49 -04:00
observer-sessions.test.js fix: port continuous-learning observer fixes 2026-05-11 03:35:42 -04:00
orchestration-session.test.js fix: retire legacy command shims from default surface 2026-04-29 23:56:40 -04:00
package-manager.test.js fix(scripts): detect modern bun.lock, ignore stray root lockfiles 2026-07-19 19:39:23 +02:00
path-safety.test.js feat(install): add guided multi-harness installer (#2649) 2026-08-06 15:39:49 -04:00
plan-canvas-markdown.test.js fix(plan-canvas): stop dropping list items when a block's first item is over-indented (#2501) 2026-07-17 17:10:58 -04:00
plan-canvas-sessions.test.js feat: Plan Canvas, a browser review canvas for plans (#2467) 2026-07-08 17:12:48 -04:00
project-detect.test.js fix(project-detect): parse Python deps pinned with `~` and `@` (was losing framework detection on compatible-release pins) (#2498) 2026-07-17 17:11:09 -04:00
resolve-ecc-root.test.js fix(commands): probe for auto-update.js in auto-update ECC_ROOT resolver (#2462) 2026-08-04 00:28:59 -04:00
resolve-formatter.test.js fix: harden Trae install ownership (#1013) 2026-03-30 02:01:54 -04:00
selective-install.test.js fix: flatten Claude skill installs (#2582) 2026-07-26 03:20:06 -07:00
session-adapters-codex.test.js feat: extend session-adapter layer with codex-worktree + opencode adapters (#2145) 2026-06-06 03:55:00 +08:00
session-adapters-opencode.test.js feat: extend session-adapter layer with codex-worktree + opencode adapters (#2145) 2026-06-06 03:55:00 +08:00
session-adapters.test.js test: cover session adapter edge cases 2026-04-29 18:21:31 -04:00
session-aliases.test.js test: skip chmod-based permission tests when running as root (#2171) 2026-06-07 13:25:53 +08:00
session-bridge.test.js test(lib): make concurrent-write test actually concurrent + use regex matcher for assert.throws 2026-05-19 04:57:10 -04:00
session-manager.test.js refactor: consolidate duplicated hook-root resolver into shared resolveEccRoot() (#2368) (#2410) 2026-07-03 20:01:17 -07:00
setup-readline-cancellation.test.js feat(install): add guided multi-harness installer (#2649) 2026-08-06 15:39:49 -04:00
shell-split.test.js
shell-substitution.test.js fix(hooks,lib): fix hook detection and parsing edge cases (#2405) 2026-07-28 21:32:42 -04:00
skill-dashboard.test.js test: cover skill dashboard edge paths 2026-04-29 19:15:47 -04:00
skill-evolution.test.js test: cover skill tracker edge paths 2026-04-29 19:21:03 -04:00
skill-improvement.test.js
state-store.test.js feat: sync GitHub queue into work items 2026-05-11 13:07:29 -04:00
terminal-spinner.test.js feat(install): add guided multi-harness installer (#2649) 2026-08-06 15:39:49 -04:00
terminal-welcome.test.js feat(install): add guided multi-harness installer (#2649) 2026-08-06 15:39:49 -04:00
tmux-worktree-orchestrator.test.js fix: retire legacy command shims from default surface 2026-04-29 23:56:40 -04:00
transcript-context.test.js fix: add claude-opus-5 to KNOWN_MODEL_WINDOW_TOKENS (#2609) 2026-08-04 00:27:33 -04:00
utils.test.js fix(hooks,lib): fix hook detection and parsing edge cases (#2405) 2026-07-28 21:32:42 -04:00
worktree-lifecycle.test.js feat: worktree-lifecycle service (deterministic conflict prediction + safe GC) (#2164) 2026-06-07 13:00:08 +08:00