@isaacriehm/cairn-core 0.2.0 → 0.3.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/dist/.tsbuildinfo +1 -1
- package/dist/claude/runner.d.ts +1 -1
- package/dist/claude/runner.js +62 -1
- package/dist/claude/runner.js.map +1 -1
- package/dist/claude/types.d.ts +14 -7
- package/dist/claude/types.js +5 -7
- package/dist/claude/types.js.map +1 -1
- package/dist/context/index.d.ts +4 -4
- package/dist/context/index.js +3 -4
- package/dist/context/index.js.map +1 -1
- package/dist/context/spec-delta.js +2 -3
- package/dist/context/spec-delta.js.map +1 -1
- package/dist/context/task-summary.d.ts +18 -0
- package/dist/context/task-summary.js +89 -0
- package/dist/context/task-summary.js.map +1 -0
- package/dist/decision-capture/id.d.ts +21 -4
- package/dist/decision-capture/id.js +56 -5
- package/dist/decision-capture/id.js.map +1 -1
- package/dist/decision-capture/index.d.ts +7 -22
- package/dist/decision-capture/index.js +7 -17
- package/dist/decision-capture/index.js.map +1 -1
- package/dist/doctor/index.d.ts +1 -1
- package/dist/doctor/index.js +1 -1
- package/dist/events/index.d.ts +1 -1
- package/dist/events/index.js +1 -1
- package/dist/events/writer.d.ts +1 -1
- package/dist/events/writer.js +1 -1
- package/dist/gc/canary.d.ts +13 -23
- package/dist/gc/canary.js +36 -92
- package/dist/gc/canary.js.map +1 -1
- package/dist/gc/citation-integrity.d.ts +6 -6
- package/dist/gc/citation-integrity.js +64 -20
- package/dist/gc/citation-integrity.js.map +1 -1
- package/dist/gc/frontmatter.js +1 -1
- package/dist/gc/generator-drift.js +1 -1
- package/dist/gc/generator-drift.js.map +1 -1
- package/dist/gc/index.d.ts +2 -2
- package/dist/gc/index.js +1 -1
- package/dist/gc/index.js.map +1 -1
- package/dist/gc/quality-update.js +1 -1
- package/dist/gc/quality-update.js.map +1 -1
- package/dist/gc/types.d.ts +1 -30
- package/dist/ground/index.d.ts +2 -2
- package/dist/ground/index.js +1 -1
- package/dist/ground/index.js.map +1 -1
- package/dist/ground/ledgers.d.ts +0 -4
- package/dist/ground/ledgers.js +10 -8
- package/dist/ground/ledgers.js.map +1 -1
- package/dist/ground/manifest.js +0 -2
- package/dist/ground/manifest.js.map +1 -1
- package/dist/ground/quality-grades.js +3 -1
- package/dist/ground/quality-grades.js.map +1 -1
- package/dist/ground/schemas.d.ts +2 -7
- package/dist/ground/schemas.js +7 -2
- package/dist/ground/schemas.js.map +1 -1
- package/dist/ground/scope-index.d.ts +59 -12
- package/dist/ground/scope-index.js +212 -43
- package/dist/ground/scope-index.js.map +1 -1
- package/dist/hooks/bypass-detection.js +4 -2
- package/dist/hooks/bypass-detection.js.map +1 -1
- package/dist/hooks/post-tool-use/citation-scanner.d.ts +7 -5
- package/dist/hooks/post-tool-use/citation-scanner.js +15 -9
- package/dist/hooks/post-tool-use/citation-scanner.js.map +1 -1
- package/dist/hooks/post-tool-use/copy-scanner.js +1 -1
- package/dist/hooks/post-tool-use/copy-scanner.js.map +1 -1
- package/dist/hooks/post-tool-use/ledger-cache.d.ts +8 -0
- package/dist/hooks/post-tool-use/ledger-cache.js +53 -0
- package/dist/hooks/post-tool-use/ledger-cache.js.map +1 -1
- package/dist/hooks/post-tool-use/legend-builder.d.ts +3 -3
- package/dist/hooks/post-tool-use/legend-builder.js +30 -8
- package/dist/hooks/post-tool-use/legend-builder.js.map +1 -1
- package/dist/hooks/post-tool-use/read-enricher.d.ts +1 -1
- package/dist/hooks/post-tool-use/read-enricher.js +68 -21
- package/dist/hooks/post-tool-use/read-enricher.js.map +1 -1
- package/dist/hooks/post-tool-use/write-guardian.js +148 -18
- package/dist/hooks/post-tool-use/write-guardian.js.map +1 -1
- package/dist/hooks/runners/index.d.ts +1 -0
- package/dist/hooks/runners/index.js +1 -0
- package/dist/hooks/runners/index.js.map +1 -1
- package/dist/hooks/runners/payload.d.ts +1 -1
- package/dist/hooks/runners/payload.js +27 -12
- package/dist/hooks/runners/payload.js.map +1 -1
- package/dist/hooks/runners/session-start.js +212 -66
- package/dist/hooks/runners/session-start.js.map +1 -1
- package/dist/hooks/runners/stop.d.ts +9 -12
- package/dist/hooks/runners/stop.js +67 -36
- package/dist/hooks/runners/stop.js.map +1 -1
- package/dist/hooks/runners/user-prompt-submit.d.ts +15 -0
- package/dist/hooks/runners/user-prompt-submit.js +149 -0
- package/dist/hooks/runners/user-prompt-submit.js.map +1 -0
- package/dist/hooks/user-prompt-submit.d.ts +7 -0
- package/dist/hooks/user-prompt-submit.js +12 -0
- package/dist/hooks/user-prompt-submit.js.map +1 -0
- package/dist/index.d.ts +1 -6
- package/dist/index.js +1 -5
- package/dist/index.js.map +1 -1
- package/dist/init/baseline-audit.d.ts +5 -1
- package/dist/init/baseline-audit.js +25 -2
- package/dist/init/baseline-audit.js.map +1 -1
- package/dist/init/glob-inference.d.ts +16 -0
- package/dist/init/glob-inference.js +108 -0
- package/dist/init/glob-inference.js.map +1 -0
- package/dist/init/index.d.ts +2 -0
- package/dist/init/index.js +1 -0
- package/dist/init/index.js.map +1 -1
- package/dist/init/ingest-docs.d.ts +1 -1
- package/dist/init/ingest-docs.js +19 -6
- package/dist/init/ingest-docs.js.map +1 -1
- package/dist/init/init.js +12 -7
- package/dist/init/init.js.map +1 -1
- package/dist/init/mapper-merge.d.ts +8 -2
- package/dist/init/mapper-merge.js +50 -32
- package/dist/init/mapper-merge.js.map +1 -1
- package/dist/init/mapper-parallel.d.ts +2 -3
- package/dist/init/mapper-parallel.js +9 -38
- package/dist/init/mapper-parallel.js.map +1 -1
- package/dist/init/mapper-prompts.js +1 -1
- package/dist/init/mapper-prompts.js.map +1 -1
- package/dist/init/mapper.d.ts +6 -127
- package/dist/init/mapper.js +30 -7
- package/dist/init/mapper.js.map +1 -1
- package/dist/init/module-slicer.d.ts +1 -1
- package/dist/init/module-slicer.js +1 -1
- package/dist/init/multi-dev/install.d.ts +5 -11
- package/dist/init/multi-dev/install.js +4 -6
- package/dist/init/multi-dev/install.js.map +1 -1
- package/dist/init/overlay.d.ts +2 -2
- package/dist/init/overlay.js +1 -1
- package/dist/init/overlay.js.map +1 -1
- package/dist/init/phases/10-strip.js +1 -2
- package/dist/init/phases/10-strip.js.map +1 -1
- package/dist/init/phases/12-multidev.d.ts +1 -6
- package/dist/init/phases/12-multidev.js +1 -6
- package/dist/init/phases/12-multidev.js.map +1 -1
- package/dist/init/phases/3b-seed.d.ts +1 -10
- package/dist/init/phases/3b-seed.js +1 -10
- package/dist/init/phases/3b-seed.js.map +1 -1
- package/dist/init/phases/4-pilot.js +53 -15
- package/dist/init/phases/4-pilot.js.map +1 -1
- package/dist/init/phases/5-brand.js +10 -10
- package/dist/init/phases/5-brand.js.map +1 -1
- package/dist/init/prompts.d.ts +6 -8
- package/dist/init/prompts.js +3 -6
- package/dist/init/prompts.js.map +1 -1
- package/dist/init/rules-merge/ingest.js +1 -1
- package/dist/init/source-comments/classify.d.ts +1 -41
- package/dist/init/source-comments/classify.js +68 -37
- package/dist/init/source-comments/classify.js.map +1 -1
- package/dist/init/source-comments/index.d.ts +2 -2
- package/dist/init/source-comments/index.js +2 -2
- package/dist/init/source-comments/index.js.map +1 -1
- package/dist/init/source-comments/ingest.d.ts +38 -2
- package/dist/init/source-comments/ingest.js +237 -4
- package/dist/init/source-comments/ingest.js.map +1 -1
- package/dist/init/source-comments/strip-replace.d.ts +10 -19
- package/dist/init/source-comments/strip-replace.js +26 -2
- package/dist/init/source-comments/strip-replace.js.map +1 -1
- package/dist/init/source-comments/walker.d.ts +9 -2
- package/dist/init/source-comments/walker.js +38 -19
- package/dist/init/source-comments/walker.js.map +1 -1
- package/dist/init/submodules.d.ts +3 -2
- package/dist/init/types.d.ts +3 -5
- package/dist/init/types.js +3 -5
- package/dist/init/types.js.map +1 -1
- package/dist/init/visual.d.ts +4 -9
- package/dist/init/visual.js +1 -16
- package/dist/init/visual.js.map +1 -1
- package/dist/logger.d.ts +0 -1
- package/dist/logger.js +0 -1
- package/dist/logger.js.map +1 -1
- package/dist/mcp/context.d.ts +2 -3
- package/dist/mcp/context.js.map +1 -1
- package/dist/mcp/errors.d.ts +1 -1
- package/dist/mcp/errors.js.map +1 -1
- package/dist/mcp/history/prompt.d.ts +2 -1
- package/dist/mcp/history/walker.js +1 -1
- package/dist/mcp/history/walker.js.map +1 -1
- package/dist/mcp/path-allowlist.d.ts +0 -6
- package/dist/mcp/path-allowlist.js +0 -10
- package/dist/mcp/path-allowlist.js.map +1 -1
- package/dist/mcp/schemas.d.ts +15 -72
- package/dist/mcp/schemas.js +21 -70
- package/dist/mcp/schemas.js.map +1 -1
- package/dist/mcp/serve.d.ts +1 -1
- package/dist/mcp/serve.js +2 -5
- package/dist/mcp/serve.js.map +1 -1
- package/dist/mcp/server.js +10 -4
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/telemetry.d.ts +8 -1
- package/dist/mcp/telemetry.js +16 -0
- package/dist/mcp/telemetry.js.map +1 -1
- package/dist/mcp/tools/decision-get.js +37 -29
- package/dist/mcp/tools/decision-get.js.map +1 -1
- package/dist/mcp/tools/decisions-in-scope.js +22 -3
- package/dist/mcp/tools/decisions-in-scope.js.map +1 -1
- package/dist/mcp/tools/index.js +2 -2
- package/dist/mcp/tools/index.js.map +1 -1
- package/dist/mcp/tools/invariant-get.js +1 -1
- package/dist/mcp/tools/invariant-get.js.map +1 -1
- package/dist/mcp/tools/invariants-in-scope.js +26 -7
- package/dist/mcp/tools/invariants-in-scope.js.map +1 -1
- package/dist/mcp/tools/query-history.js +3 -3
- package/dist/mcp/tools/query-history.js.map +1 -1
- package/dist/mcp/tools/resolve-attention.d.ts +3 -3
- package/dist/mcp/tools/resolve-attention.js +40 -28
- package/dist/mcp/tools/resolve-attention.js.map +1 -1
- package/dist/mcp/tools/search.js +3 -4
- package/dist/mcp/tools/search.js.map +1 -1
- package/dist/mcp/tools/task-create.d.ts +15 -0
- package/dist/mcp/tools/task-create.js +96 -0
- package/dist/mcp/tools/task-create.js.map +1 -0
- package/dist/mcp/tools/timeline.js +3 -7
- package/dist/mcp/tools/timeline.js.map +1 -1
- package/dist/profiles/types.d.ts +1 -1
- package/dist/profiles/types.js +1 -1
- package/dist/session/id.d.ts +1 -3
- package/dist/session/id.js +1 -1
- package/dist/session/id.js.map +1 -1
- package/dist/session-start/build.d.ts +3 -11
- package/dist/session-start/build.js +55 -34
- package/dist/session-start/build.js.map +1 -1
- package/dist/session-start/index.d.ts +2 -2
- package/dist/session-start/index.js +2 -2
- package/dist/session-start/index.js.map +1 -1
- package/dist/session-start/templates.d.ts +20 -4
- package/dist/session-start/templates.js +45 -35
- package/dist/session-start/templates.js.map +1 -1
- package/dist/status-line/format.d.ts +19 -11
- package/dist/status-line/format.js +44 -36
- package/dist/status-line/format.js.map +1 -1
- package/dist/status-line/index.d.ts +3 -1
- package/dist/status-line/index.js +1 -1
- package/dist/status-line/index.js.map +1 -1
- package/dist/status-line/reader.d.ts +9 -6
- package/dist/status-line/reader.js +50 -15
- package/dist/status-line/reader.js.map +1 -1
- package/dist/status-line/writer.d.ts +5 -0
- package/dist/status-line/writer.js +9 -0
- package/dist/status-line/writer.js.map +1 -1
- package/dist/trace/index.d.ts +44 -0
- package/dist/trace/index.js +51 -0
- package/dist/trace/index.js.map +1 -0
- package/package.json +2 -3
- package/templates/.archive/README.md +3 -3
- package/templates/.cairn/config/sensors.yaml +16 -19
- package/templates/.cairn/config/stub-patterns.yaml +4 -4
- package/templates/.cairn/config/trust-policy.yaml +3 -35
- package/templates/.cairn/config/workflow.md +13 -194
- package/templates/.cairn/git-hooks/commit-msg +1 -1
- package/templates/.cairn/ground/canonical-map/topics.yaml +3 -26
- package/templates/.cairn/ground/capabilities/snippets.yaml +0 -1
- package/templates/.cairn/ground/manifest.yaml +5 -8
- package/templates/.cairn/ground/product/personas.yaml +0 -1
- package/dist/context/checkpoint.d.ts +0 -11
- package/dist/context/checkpoint.js +0 -30
- package/dist/context/checkpoint.js.map +0 -1
- package/dist/decision-capture/capture.d.ts +0 -57
- package/dist/decision-capture/capture.js +0 -186
- package/dist/decision-capture/capture.js.map +0 -1
- package/dist/decision-capture/extractor.d.ts +0 -20
- package/dist/decision-capture/extractor.js +0 -103
- package/dist/decision-capture/extractor.js.map +0 -1
- package/dist/decision-capture/prompt.d.ts +0 -15
- package/dist/decision-capture/prompt.js +0 -68
- package/dist/decision-capture/prompt.js.map +0 -1
- package/dist/decision-capture/refinement-prompt.d.ts +0 -25
- package/dist/decision-capture/refinement-prompt.js +0 -146
- package/dist/decision-capture/refinement-prompt.js.map +0 -1
- package/dist/decision-capture/refinement-schema.d.ts +0 -52
- package/dist/decision-capture/refinement-schema.js +0 -61
- package/dist/decision-capture/refinement-schema.js.map +0 -1
- package/dist/decision-capture/refinement.d.ts +0 -60
- package/dist/decision-capture/refinement.js +0 -439
- package/dist/decision-capture/refinement.js.map +0 -1
- package/dist/decision-capture/schema.d.ts +0 -70
- package/dist/decision-capture/schema.js +0 -71
- package/dist/decision-capture/schema.js.map +0 -1
- package/dist/decision-capture/types.d.ts +0 -201
- package/dist/decision-capture/types.js +0 -20
- package/dist/decision-capture/types.js.map +0 -1
- package/dist/decision-capture/writer.d.ts +0 -90
- package/dist/decision-capture/writer.js +0 -267
- package/dist/decision-capture/writer.js.map +0 -1
- package/dist/frontend-types.d.ts +0 -243
- package/dist/frontend-types.js +0 -15
- package/dist/frontend-types.js.map +0 -1
- package/dist/hooks/index.d.ts +0 -14
- package/dist/hooks/index.js +0 -14
- package/dist/hooks/index.js.map +0 -1
- package/dist/inbox.d.ts +0 -17
- package/dist/inbox.js +0 -30
- package/dist/inbox.js.map +0 -1
- package/dist/mcp/tools/append-run-note.d.ts +0 -18
- package/dist/mcp/tools/append-run-note.js +0 -54
- package/dist/mcp/tools/append-run-note.js.map +0 -1
- package/dist/mcp/tools/append.d.ts +0 -8
- package/dist/mcp/tools/append.js +0 -37
- package/dist/mcp/tools/append.js.map +0 -1
- package/dist/mcp/tools/ask-operator.d.ts +0 -34
- package/dist/mcp/tools/ask-operator.js +0 -97
- package/dist/mcp/tools/ask-operator.js.map +0 -1
- package/dist/mcp/tools/drop-task.d.ts +0 -12
- package/dist/mcp/tools/drop-task.js +0 -68
- package/dist/mcp/tools/drop-task.js.map +0 -1
- package/dist/mcp/tools/record-run-event.d.ts +0 -10
- package/dist/mcp/tools/record-run-event.js +0 -32
- package/dist/mcp/tools/record-run-event.js.map +0 -1
- package/dist/prompt.d.ts +0 -19
- package/dist/prompt.js +0 -50
- package/dist/prompt.js.map +0 -1
- package/dist/tier0/classify.d.ts +0 -10
- package/dist/tier0/classify.js +0 -110
- package/dist/tier0/classify.js.map +0 -1
- package/dist/tier0/index.d.ts +0 -2
- package/dist/tier0/index.js +0 -2
- package/dist/tier0/index.js.map +0 -1
- package/dist/tier0/types.d.ts +0 -24
- package/dist/tier0/types.js +0 -9
- package/dist/tier0/types.js.map +0 -1
- package/dist/tightener/index.d.ts +0 -4
- package/dist/tightener/index.js +0 -4
- package/dist/tightener/index.js.map +0 -1
- package/dist/tightener/prompt.d.ts +0 -3
- package/dist/tightener/prompt.js +0 -67
- package/dist/tightener/prompt.js.map +0 -1
- package/dist/tightener/schema.d.ts +0 -68
- package/dist/tightener/schema.js +0 -44
- package/dist/tightener/schema.js.map +0 -1
- package/dist/tightener/tighten.d.ts +0 -2
- package/dist/tightener/tighten.js +0 -66
- package/dist/tightener/tighten.js.map +0 -1
- package/dist/tightener/types.d.ts +0 -74
- package/dist/tightener/types.js +0 -6
- package/dist/tightener/types.js.map +0 -1
- package/templates/.claude/settings.json +0 -57
- package/templates/.mcp.json +0 -8
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* JSON Schema enforced by `claude --json-schema` for the assertion-refiner
|
|
3
|
-
* proposer output.
|
|
4
|
-
*
|
|
5
|
-
* For each input candidate the proposer returns one `RefinementProposal`.
|
|
6
|
-
* The shape here is intentionally loose on `strict_assertion` — the
|
|
7
|
-
* production `DecisionAssertion` zod (see `src/ground/schemas.ts`) is the
|
|
8
|
-
* source of truth and re-validates at apply time. Forcing the discriminated
|
|
9
|
-
* union into JSON Schema and the proposer's prompt would burn tokens
|
|
10
|
-
* without buying additional safety, since malformed shapes auto-demote.
|
|
11
|
-
*
|
|
12
|
-
* The proposer's per-kind contract is encoded in the system prompt
|
|
13
|
-
* (`refinement-prompt.ts`), not here.
|
|
14
|
-
*/
|
|
15
|
-
export declare const REFINEMENT_PROPOSER_OUTPUT_SCHEMA: {
|
|
16
|
-
readonly type: "object";
|
|
17
|
-
readonly additionalProperties: false;
|
|
18
|
-
readonly properties: {
|
|
19
|
-
readonly proposals: {
|
|
20
|
-
readonly type: "array";
|
|
21
|
-
readonly items: {
|
|
22
|
-
readonly type: "object";
|
|
23
|
-
readonly additionalProperties: false;
|
|
24
|
-
readonly properties: {
|
|
25
|
-
readonly candidate_id: {
|
|
26
|
-
readonly type: "string";
|
|
27
|
-
readonly minLength: 1;
|
|
28
|
-
};
|
|
29
|
-
readonly candidate_kind: {
|
|
30
|
-
readonly enum: readonly ["schema_must_contain", "text_must_match", "text_must_not_match", "index_must_exist", "ast_pattern", "file_must_not_be_modified", "query_must_filter_by", "route_must_have_guard", "event_must_emit", "service_method_must_call", "human_review_hint"];
|
|
31
|
-
};
|
|
32
|
-
readonly status: {
|
|
33
|
-
readonly enum: readonly ["lift", "demote", "skip"];
|
|
34
|
-
};
|
|
35
|
-
readonly confidence_signal: {
|
|
36
|
-
readonly enum: readonly ["high", "medium", "low"];
|
|
37
|
-
};
|
|
38
|
-
readonly strict_assertion: {
|
|
39
|
-
readonly type: "object";
|
|
40
|
-
readonly additionalProperties: true;
|
|
41
|
-
};
|
|
42
|
-
readonly rationale: {
|
|
43
|
-
readonly type: "string";
|
|
44
|
-
readonly minLength: 1;
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
readonly required: readonly ["candidate_id", "candidate_kind", "status", "confidence_signal", "rationale"];
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
readonly required: readonly ["proposals"];
|
|
52
|
-
};
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* JSON Schema enforced by `claude --json-schema` for the assertion-refiner
|
|
3
|
-
* proposer output.
|
|
4
|
-
*
|
|
5
|
-
* For each input candidate the proposer returns one `RefinementProposal`.
|
|
6
|
-
* The shape here is intentionally loose on `strict_assertion` — the
|
|
7
|
-
* production `DecisionAssertion` zod (see `src/ground/schemas.ts`) is the
|
|
8
|
-
* source of truth and re-validates at apply time. Forcing the discriminated
|
|
9
|
-
* union into JSON Schema and the proposer's prompt would burn tokens
|
|
10
|
-
* without buying additional safety, since malformed shapes auto-demote.
|
|
11
|
-
*
|
|
12
|
-
* The proposer's per-kind contract is encoded in the system prompt
|
|
13
|
-
* (`refinement-prompt.ts`), not here.
|
|
14
|
-
*/
|
|
15
|
-
export const REFINEMENT_PROPOSER_OUTPUT_SCHEMA = {
|
|
16
|
-
type: "object",
|
|
17
|
-
additionalProperties: false,
|
|
18
|
-
properties: {
|
|
19
|
-
proposals: {
|
|
20
|
-
type: "array",
|
|
21
|
-
items: {
|
|
22
|
-
type: "object",
|
|
23
|
-
additionalProperties: false,
|
|
24
|
-
properties: {
|
|
25
|
-
candidate_id: { type: "string", minLength: 1 },
|
|
26
|
-
candidate_kind: {
|
|
27
|
-
enum: [
|
|
28
|
-
"schema_must_contain",
|
|
29
|
-
"text_must_match",
|
|
30
|
-
"text_must_not_match",
|
|
31
|
-
"index_must_exist",
|
|
32
|
-
"ast_pattern",
|
|
33
|
-
"file_must_not_be_modified",
|
|
34
|
-
"query_must_filter_by",
|
|
35
|
-
"route_must_have_guard",
|
|
36
|
-
"event_must_emit",
|
|
37
|
-
"service_method_must_call",
|
|
38
|
-
"human_review_hint",
|
|
39
|
-
],
|
|
40
|
-
},
|
|
41
|
-
status: { enum: ["lift", "demote", "skip"] },
|
|
42
|
-
confidence_signal: { enum: ["high", "medium", "low"] },
|
|
43
|
-
strict_assertion: {
|
|
44
|
-
type: "object",
|
|
45
|
-
additionalProperties: true,
|
|
46
|
-
},
|
|
47
|
-
rationale: { type: "string", minLength: 1 },
|
|
48
|
-
},
|
|
49
|
-
required: [
|
|
50
|
-
"candidate_id",
|
|
51
|
-
"candidate_kind",
|
|
52
|
-
"status",
|
|
53
|
-
"confidence_signal",
|
|
54
|
-
"rationale",
|
|
55
|
-
],
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
required: ["proposals"],
|
|
60
|
-
};
|
|
61
|
-
//# sourceMappingURL=refinement-schema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"refinement-schema.js","sourceRoot":"","sources":["../../src/decision-capture/refinement-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG;IAC/C,IAAI,EAAE,QAAQ;IACd,oBAAoB,EAAE,KAAK;IAC3B,UAAU,EAAE;QACV,SAAS,EAAE;YACT,IAAI,EAAE,OAAO;YACb,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,oBAAoB,EAAE,KAAK;gBAC3B,UAAU,EAAE;oBACV,YAAY,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,EAAE;oBAC9C,cAAc,EAAE;wBACd,IAAI,EAAE;4BACJ,qBAAqB;4BACrB,iBAAiB;4BACjB,qBAAqB;4BACrB,kBAAkB;4BAClB,aAAa;4BACb,2BAA2B;4BAC3B,sBAAsB;4BACtB,uBAAuB;4BACvB,iBAAiB;4BACjB,0BAA0B;4BAC1B,mBAAmB;yBACpB;qBACF;oBACD,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE;oBAC5C,iBAAiB,EAAE,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,EAAE;oBACtD,gBAAgB,EAAE;wBAChB,IAAI,EAAE,QAAQ;wBACd,oBAAoB,EAAE,IAAI;qBAC3B;oBACD,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,EAAE;iBAC5C;gBACD,QAAQ,EAAE;oBACR,cAAc;oBACd,gBAAgB;oBAChB,QAAQ;oBACR,mBAAmB;oBACnB,WAAW;iBACZ;aACF;SACF;KACF;IACD,QAAQ,EAAE,CAAC,WAAW,CAAC;CACf,CAAC"}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Phase 14.x — assertion refinement.
|
|
3
|
-
*
|
|
4
|
-
* Lifts the loose `candidate_assertions:` set on an accepted decision into
|
|
5
|
-
* the strict `assertions:` shape that Layer-D sensors enforce.
|
|
6
|
-
*
|
|
7
|
-
* Flow:
|
|
8
|
-
* read accepted decision file
|
|
9
|
-
* → proposeStrictAssertions (Tier-1 LLM)
|
|
10
|
-
* → re-validate each lift via DecisionAssertion zod (auto-demote on fail)
|
|
11
|
-
* → adapter.requestDialog: a) approve_all b) approve_high_only
|
|
12
|
-
* c) demote_all d) skip
|
|
13
|
-
* → liftCandidatesToAssertions writes the file
|
|
14
|
-
* → ledger regenerates so the new strict assertions become live
|
|
15
|
-
*
|
|
16
|
-
* The proposer runs READ-ONLY. The writer + dialog drive everything that
|
|
17
|
-
* touches the filesystem. A proposer failure (timeout, malformed JSON,
|
|
18
|
-
* subprocess crash) does NOT roll back the prior accept — it returns
|
|
19
|
-
* `proposer_failed: true` and leaves candidates under their loose
|
|
20
|
-
* `candidate_assertions:` field for the next refine pass.
|
|
21
|
-
*/
|
|
22
|
-
import type { FrontendAdapter } from "../frontend-types.js";
|
|
23
|
-
import type { ClaudeTier } from "../claude/index.js";
|
|
24
|
-
import type { RefinementResult, RefinerInput, RefinerOutput } from "./types.js";
|
|
25
|
-
export interface ProposerResult {
|
|
26
|
-
output: RefinerOutput;
|
|
27
|
-
duration_ms: number;
|
|
28
|
-
usage?: {
|
|
29
|
-
input_tokens?: number;
|
|
30
|
-
output_tokens?: number;
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Single Tier-1 (Haiku default) LLM call producing one proposal per
|
|
35
|
-
* input candidate. The output is gated by the JSON Schema on the CLI
|
|
36
|
-
* side and re-validated structurally here.
|
|
37
|
-
*/
|
|
38
|
-
export declare function proposeStrictAssertions(input: RefinerInput): Promise<ProposerResult>;
|
|
39
|
-
export interface RunDecisionRefinementArgs {
|
|
40
|
-
/** Repo root for the mirror checkout. */
|
|
41
|
-
repoRoot: string;
|
|
42
|
-
/** DEC-id of the accepted decision whose candidates we're refining. */
|
|
43
|
-
decisionId: string;
|
|
44
|
-
/** Adapter that owns the confirm dialog. */
|
|
45
|
-
adapter: FrontendAdapter;
|
|
46
|
-
/** Channel for the dialog (Discord thread / DM). */
|
|
47
|
-
channelId?: string;
|
|
48
|
-
/** Tier for the proposer call. Default = haiku. */
|
|
49
|
-
tier?: ClaudeTier;
|
|
50
|
-
/** Per-call timeout for the proposer. */
|
|
51
|
-
proposerTimeoutMs?: number;
|
|
52
|
-
/** Dialog timeout. Default 60_000 ms. */
|
|
53
|
-
dialogTimeoutMs?: number;
|
|
54
|
-
/**
|
|
55
|
-
* Smokes inject a stub here so they can verify dialog branching without
|
|
56
|
-
* burning claude quota. Defaults to `proposeStrictAssertions`.
|
|
57
|
-
*/
|
|
58
|
-
proposerOverride?: typeof proposeStrictAssertions;
|
|
59
|
-
}
|
|
60
|
-
export declare function runDecisionRefinement(args: RunDecisionRefinementArgs): Promise<RefinementResult>;
|
|
@@ -1,439 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Phase 14.x — assertion refinement.
|
|
3
|
-
*
|
|
4
|
-
* Lifts the loose `candidate_assertions:` set on an accepted decision into
|
|
5
|
-
* the strict `assertions:` shape that Layer-D sensors enforce.
|
|
6
|
-
*
|
|
7
|
-
* Flow:
|
|
8
|
-
* read accepted decision file
|
|
9
|
-
* → proposeStrictAssertions (Tier-1 LLM)
|
|
10
|
-
* → re-validate each lift via DecisionAssertion zod (auto-demote on fail)
|
|
11
|
-
* → adapter.requestDialog: a) approve_all b) approve_high_only
|
|
12
|
-
* c) demote_all d) skip
|
|
13
|
-
* → liftCandidatesToAssertions writes the file
|
|
14
|
-
* → ledger regenerates so the new strict assertions become live
|
|
15
|
-
*
|
|
16
|
-
* The proposer runs READ-ONLY. The writer + dialog drive everything that
|
|
17
|
-
* touches the filesystem. A proposer failure (timeout, malformed JSON,
|
|
18
|
-
* subprocess crash) does NOT roll back the prior accept — it returns
|
|
19
|
-
* `proposer_failed: true` and leaves candidates under their loose
|
|
20
|
-
* `candidate_assertions:` field for the next refine pass.
|
|
21
|
-
*/
|
|
22
|
-
import { readFileSync } from "node:fs";
|
|
23
|
-
import { join } from "node:path";
|
|
24
|
-
import { logger } from "../logger.js";
|
|
25
|
-
import { runClaude } from "../claude/index.js";
|
|
26
|
-
import { DecisionAssertion } from "../ground/schemas.js";
|
|
27
|
-
import { parseFrontmatter } from "../ground/frontmatter.js";
|
|
28
|
-
import { REFINEMENT_PROPOSER_SYSTEM_PROMPT, buildRefinementProposerUserPrompt, } from "./refinement-prompt.js";
|
|
29
|
-
import { REFINEMENT_PROPOSER_OUTPUT_SCHEMA } from "./refinement-schema.js";
|
|
30
|
-
import { liftCandidatesToAssertions } from "./writer.js";
|
|
31
|
-
const log = logger("decision-capture.refinement");
|
|
32
|
-
const RATIONALE_DISPLAY_CAP = 240;
|
|
33
|
-
/** Max chars in the refinement dialog prompt body. Discord caps at 2000. */
|
|
34
|
-
const DIALOG_PROMPT_CHAR_CAP = 1_700;
|
|
35
|
-
const CHOICE_APPROVE_ALL = "a";
|
|
36
|
-
const CHOICE_APPROVE_HIGH_ONLY = "b";
|
|
37
|
-
const CHOICE_DEMOTE_ALL = "c";
|
|
38
|
-
const CHOICE_SKIP = "d";
|
|
39
|
-
/**
|
|
40
|
-
* Single Tier-1 (Haiku default) LLM call producing one proposal per
|
|
41
|
-
* input candidate. The output is gated by the JSON Schema on the CLI
|
|
42
|
-
* side and re-validated structurally here.
|
|
43
|
-
*/
|
|
44
|
-
export async function proposeStrictAssertions(input) {
|
|
45
|
-
if (input.candidates.length === 0) {
|
|
46
|
-
return { output: { proposals: [] }, duration_ms: 0 };
|
|
47
|
-
}
|
|
48
|
-
const userPrompt = buildRefinementProposerUserPrompt(input);
|
|
49
|
-
log.info({
|
|
50
|
-
decision_id: input.decision_id,
|
|
51
|
-
candidates: input.candidates.length,
|
|
52
|
-
tier: input.tier,
|
|
53
|
-
}, "refinement-proposer dispatch");
|
|
54
|
-
const result = await runClaude({
|
|
55
|
-
tier: input.tier,
|
|
56
|
-
prompt: userPrompt,
|
|
57
|
-
system: REFINEMENT_PROPOSER_SYSTEM_PROMPT,
|
|
58
|
-
jsonSchema: REFINEMENT_PROPOSER_OUTPUT_SCHEMA,
|
|
59
|
-
timeoutMs: input.timeout_ms ?? 120_000,
|
|
60
|
-
});
|
|
61
|
-
if (!isRefinerOutput(result.parsed)) {
|
|
62
|
-
throw new Error(`refinement-proposer returned malformed output. preview: ${result.text.slice(0, 200)}`);
|
|
63
|
-
}
|
|
64
|
-
log.info({
|
|
65
|
-
decision_id: input.decision_id,
|
|
66
|
-
proposals: result.parsed.proposals.length,
|
|
67
|
-
duration_ms: result.durationMs,
|
|
68
|
-
}, "refinement-proposer complete");
|
|
69
|
-
return {
|
|
70
|
-
output: result.parsed,
|
|
71
|
-
duration_ms: result.durationMs,
|
|
72
|
-
...(result.usage !== undefined
|
|
73
|
-
? {
|
|
74
|
-
usage: {
|
|
75
|
-
...(result.usage["input_tokens"] !== undefined
|
|
76
|
-
? { input_tokens: result.usage["input_tokens"] }
|
|
77
|
-
: {}),
|
|
78
|
-
...(result.usage["output_tokens"] !== undefined
|
|
79
|
-
? { output_tokens: result.usage["output_tokens"] }
|
|
80
|
-
: {}),
|
|
81
|
-
},
|
|
82
|
-
}
|
|
83
|
-
: {}),
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
export async function runDecisionRefinement(args) {
|
|
87
|
-
const tier = args.tier ?? "haiku";
|
|
88
|
-
const propose = args.proposerOverride ?? proposeStrictAssertions;
|
|
89
|
-
const decision = readAcceptedDecision({
|
|
90
|
-
repoRoot: args.repoRoot,
|
|
91
|
-
decisionId: args.decisionId,
|
|
92
|
-
});
|
|
93
|
-
if (decision.candidates.length === 0) {
|
|
94
|
-
log.info({ decision_id: args.decisionId }, "no candidates to refine — skipping");
|
|
95
|
-
return emptyResult(args.decisionId, "skip");
|
|
96
|
-
}
|
|
97
|
-
let proposerResult = null;
|
|
98
|
-
try {
|
|
99
|
-
proposerResult = await propose({
|
|
100
|
-
decision_id: args.decisionId,
|
|
101
|
-
subject: decision.subject,
|
|
102
|
-
summary: decision.summary,
|
|
103
|
-
scope_globs: decision.scope_globs,
|
|
104
|
-
candidates: decision.candidates,
|
|
105
|
-
tier,
|
|
106
|
-
...(args.proposerTimeoutMs !== undefined
|
|
107
|
-
? { timeout_ms: args.proposerTimeoutMs }
|
|
108
|
-
: {}),
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
catch (err) {
|
|
112
|
-
log.error({ err: String(err), decision_id: args.decisionId }, "refinement-proposer threw — leaving candidates loose");
|
|
113
|
-
return { ...emptyResult(args.decisionId, "skip"), proposer_failed: true };
|
|
114
|
-
}
|
|
115
|
-
// Align proposals to candidates by id; fill gaps with auto-demote so a
|
|
116
|
-
// partial proposer response never silently drops a candidate.
|
|
117
|
-
const aligned = alignProposalsToCandidates({
|
|
118
|
-
decisionId: args.decisionId,
|
|
119
|
-
candidates: decision.candidates,
|
|
120
|
-
proposals: proposerResult.output.proposals,
|
|
121
|
-
});
|
|
122
|
-
// Re-validate each lift via the production zod. Anything that doesn't
|
|
123
|
-
// pass becomes a demote with the validation error in the rationale.
|
|
124
|
-
const validated = aligned.map((p) => validateLift(p));
|
|
125
|
-
const dialogPrompt = renderDialogPrompt({
|
|
126
|
-
decisionId: args.decisionId,
|
|
127
|
-
subject: decision.subject,
|
|
128
|
-
proposals: validated,
|
|
129
|
-
});
|
|
130
|
-
const dialogSpec = {
|
|
131
|
-
bundleId: `refine:${args.decisionId}`,
|
|
132
|
-
prompt: dialogPrompt,
|
|
133
|
-
choices: [
|
|
134
|
-
{ id: CHOICE_APPROVE_ALL, label: "🟢 approve all (lift + demote per recs)" },
|
|
135
|
-
{ id: CHOICE_APPROVE_HIGH_ONLY, label: "🟡 lift HIGH-confidence only" },
|
|
136
|
-
{ id: CHOICE_DEMOTE_ALL, label: "🟠 demote all to human_review_hint" },
|
|
137
|
-
{ id: CHOICE_SKIP, label: "🔴 skip refinement" },
|
|
138
|
-
{ id: "e_other", label: "E) Other" },
|
|
139
|
-
],
|
|
140
|
-
timeoutMs: args.dialogTimeoutMs ?? 60_000,
|
|
141
|
-
};
|
|
142
|
-
if (args.channelId !== undefined)
|
|
143
|
-
dialogSpec.channelId = args.channelId;
|
|
144
|
-
const response = await args.adapter.requestDialog(dialogSpec);
|
|
145
|
-
const choice = mapDialogChoice(response);
|
|
146
|
-
// Compose the final per-candidate verdict map from the operator's choice.
|
|
147
|
-
const finalVerdicts = applyOperatorChoice({
|
|
148
|
-
proposals: validated,
|
|
149
|
-
candidates: decision.candidates,
|
|
150
|
-
choice,
|
|
151
|
-
});
|
|
152
|
-
if (choice === "skip") {
|
|
153
|
-
log.info({ decision_id: args.decisionId }, "operator skipped refinement");
|
|
154
|
-
return {
|
|
155
|
-
decision_id: args.decisionId,
|
|
156
|
-
proposals: validated,
|
|
157
|
-
operator_choice: "skip",
|
|
158
|
-
lifted_count: 0,
|
|
159
|
-
demoted_count: 0,
|
|
160
|
-
skipped_count: validated.length,
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
const liftResult = liftCandidatesToAssertions({
|
|
164
|
-
repoRoot: args.repoRoot,
|
|
165
|
-
decisionId: args.decisionId,
|
|
166
|
-
verdicts: finalVerdicts,
|
|
167
|
-
});
|
|
168
|
-
log.info({
|
|
169
|
-
decision_id: args.decisionId,
|
|
170
|
-
operator_choice: choice,
|
|
171
|
-
lifted: liftResult.lifted_count,
|
|
172
|
-
demoted: liftResult.demoted_count,
|
|
173
|
-
kept_candidate: liftResult.skipped_count,
|
|
174
|
-
}, "refinement applied");
|
|
175
|
-
return {
|
|
176
|
-
decision_id: args.decisionId,
|
|
177
|
-
proposals: validated,
|
|
178
|
-
operator_choice: choice,
|
|
179
|
-
lifted_count: liftResult.lifted_count,
|
|
180
|
-
demoted_count: liftResult.demoted_count,
|
|
181
|
-
skipped_count: liftResult.skipped_count,
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
function readAcceptedDecision(args) {
|
|
185
|
-
const relPath = `.cairn/ground/decisions/${args.decisionId}.md`;
|
|
186
|
-
const abs = join(args.repoRoot, relPath);
|
|
187
|
-
const raw = readFileSync(abs, "utf8");
|
|
188
|
-
// parseFrontmatter validates with ProvenanceFrontmatter zod which is a
|
|
189
|
-
// passthrough — extra keys (candidate_assertions, scope_globs, title)
|
|
190
|
-
// survive in the returned object.
|
|
191
|
-
const parsed = parseFrontmatter(raw);
|
|
192
|
-
const fm = (parsed.frontmatter ?? {});
|
|
193
|
-
const candidatesRaw = fm["candidate_assertions"];
|
|
194
|
-
const candidates = Array.isArray(candidatesRaw)
|
|
195
|
-
? candidatesRaw.flatMap((c, idx) => {
|
|
196
|
-
const kind = c["kind"];
|
|
197
|
-
const description = c["description"];
|
|
198
|
-
if (typeof kind !== "string" || typeof description !== "string") {
|
|
199
|
-
log.warn({ decision_id: args.decisionId, idx }, "dropping malformed candidate row from frontmatter");
|
|
200
|
-
return [];
|
|
201
|
-
}
|
|
202
|
-
const id = typeof c["id"] === "string"
|
|
203
|
-
? c["id"]
|
|
204
|
-
: `${args.decisionId}-A${(idx + 1).toString().padStart(2, "0")}`;
|
|
205
|
-
const params = c["parameters"];
|
|
206
|
-
const out = {
|
|
207
|
-
id,
|
|
208
|
-
kind: kind,
|
|
209
|
-
description,
|
|
210
|
-
...(params !== undefined && typeof params === "object" && params !== null
|
|
211
|
-
? { parameters: params }
|
|
212
|
-
: {}),
|
|
213
|
-
};
|
|
214
|
-
return [out];
|
|
215
|
-
})
|
|
216
|
-
: [];
|
|
217
|
-
return {
|
|
218
|
-
subject: typeof fm["title"] === "string" ? fm["title"] : args.decisionId,
|
|
219
|
-
summary: extractSummaryFromBody(parsed.body),
|
|
220
|
-
scope_globs: Array.isArray(fm["scope_globs"])
|
|
221
|
-
? fm["scope_globs"].filter((g) => typeof g === "string")
|
|
222
|
-
: [],
|
|
223
|
-
candidates,
|
|
224
|
-
};
|
|
225
|
-
}
|
|
226
|
-
function extractSummaryFromBody(body) {
|
|
227
|
-
// Body starts with `# DEC-NNNN — title\n\n## Summary\n<text>\n\n## ...`
|
|
228
|
-
const summaryHeader = body.indexOf("## Summary");
|
|
229
|
-
if (summaryHeader === -1)
|
|
230
|
-
return "";
|
|
231
|
-
const after = body.slice(summaryHeader + "## Summary".length);
|
|
232
|
-
const nextSection = after.search(/\n##\s/);
|
|
233
|
-
const slice = nextSection === -1 ? after : after.slice(0, nextSection);
|
|
234
|
-
return slice.trim();
|
|
235
|
-
}
|
|
236
|
-
function alignProposalsToCandidates(args) {
|
|
237
|
-
const byId = new Map();
|
|
238
|
-
for (const p of args.proposals)
|
|
239
|
-
byId.set(p.candidate_id, p);
|
|
240
|
-
return args.candidates.map((c, idx) => {
|
|
241
|
-
const id = c.id ?? `${args.decisionId}-A${(idx + 1).toString().padStart(2, "0")}`;
|
|
242
|
-
const found = byId.get(id);
|
|
243
|
-
if (found !== undefined)
|
|
244
|
-
return found;
|
|
245
|
-
log.warn({ decision_id: args.decisionId, candidate_id: id }, "proposer dropped a candidate — auto-demoting");
|
|
246
|
-
return {
|
|
247
|
-
candidate_id: id,
|
|
248
|
-
candidate_kind: c.kind,
|
|
249
|
-
status: "demote",
|
|
250
|
-
confidence_signal: "low",
|
|
251
|
-
rationale: "auto-demoted: proposer did not return a proposal for this candidate",
|
|
252
|
-
};
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
function validateLift(p) {
|
|
256
|
-
if (p.status !== "lift")
|
|
257
|
-
return p;
|
|
258
|
-
// human_review_hint always lifts cleanly: the strict shape only requires
|
|
259
|
-
// `description`. If the proposer didn't provide one, fall back to the
|
|
260
|
-
// candidate kind's name.
|
|
261
|
-
if (p.candidate_kind === "human_review_hint") {
|
|
262
|
-
const description = typeof p.strict_assertion?.["description"] === "string"
|
|
263
|
-
? p.strict_assertion["description"]
|
|
264
|
-
: (p.rationale || "human review required");
|
|
265
|
-
return {
|
|
266
|
-
...p,
|
|
267
|
-
strict_assertion: { description },
|
|
268
|
-
};
|
|
269
|
-
}
|
|
270
|
-
if (p.strict_assertion === undefined) {
|
|
271
|
-
const { strict_assertion: _omit, ...rest } = p;
|
|
272
|
-
void _omit;
|
|
273
|
-
return {
|
|
274
|
-
...rest,
|
|
275
|
-
status: "demote",
|
|
276
|
-
rationale: `auto-demoted: lift verdict missing strict_assertion. Original rationale: ${p.rationale}`,
|
|
277
|
-
};
|
|
278
|
-
}
|
|
279
|
-
// Inject id + kind to match the discriminated DecisionAssertion zod.
|
|
280
|
-
// Note: id is a placeholder for validation only; the writer mints the
|
|
281
|
-
// canonical `<DEC-id>-A<NN>` id before persisting.
|
|
282
|
-
const candidate = {
|
|
283
|
-
id: p.candidate_id,
|
|
284
|
-
kind: p.candidate_kind,
|
|
285
|
-
...p.strict_assertion,
|
|
286
|
-
};
|
|
287
|
-
const parse = DecisionAssertion.safeParse(candidate);
|
|
288
|
-
if (!parse.success) {
|
|
289
|
-
const { strict_assertion: _omit, ...rest } = p;
|
|
290
|
-
void _omit;
|
|
291
|
-
return {
|
|
292
|
-
...rest,
|
|
293
|
-
status: "demote",
|
|
294
|
-
rationale: `auto-demoted: zod validation failed (${parse.error.issues.map((e) => `${e.path.join(".")}: ${e.message}`).slice(0, 2).join("; ")})`,
|
|
295
|
-
};
|
|
296
|
-
}
|
|
297
|
-
return p;
|
|
298
|
-
}
|
|
299
|
-
function mapDialogChoice(response) {
|
|
300
|
-
if (response.timedOut)
|
|
301
|
-
return "skip";
|
|
302
|
-
switch (response.choiceId) {
|
|
303
|
-
case CHOICE_APPROVE_ALL:
|
|
304
|
-
return "approve_all";
|
|
305
|
-
case CHOICE_APPROVE_HIGH_ONLY:
|
|
306
|
-
return "approve_high_only";
|
|
307
|
-
case CHOICE_DEMOTE_ALL:
|
|
308
|
-
return "demote_all";
|
|
309
|
-
case CHOICE_SKIP:
|
|
310
|
-
return "skip";
|
|
311
|
-
default:
|
|
312
|
-
// Unknown / E) Other → conservative skip; preserves candidates.
|
|
313
|
-
return "skip";
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
function applyOperatorChoice(args) {
|
|
317
|
-
const descById = new Map();
|
|
318
|
-
for (let i = 0; i < args.candidates.length; i++) {
|
|
319
|
-
const c = args.candidates[i];
|
|
320
|
-
if (c === undefined)
|
|
321
|
-
continue;
|
|
322
|
-
const id = c.id ?? `unknown-A${(i + 1).toString().padStart(2, "0")}`;
|
|
323
|
-
descById.set(id, c.description);
|
|
324
|
-
}
|
|
325
|
-
return args.proposals.map((p) => {
|
|
326
|
-
const description = descById.get(p.candidate_id) ?? p.rationale;
|
|
327
|
-
const base = {
|
|
328
|
-
candidate_id: p.candidate_id,
|
|
329
|
-
candidate_kind: p.candidate_kind,
|
|
330
|
-
candidate_description: description,
|
|
331
|
-
status: "skip",
|
|
332
|
-
};
|
|
333
|
-
if (args.choice === "skip") {
|
|
334
|
-
return { ...base, status: "skip" };
|
|
335
|
-
}
|
|
336
|
-
if (args.choice === "demote_all") {
|
|
337
|
-
return { ...base, status: "demote" };
|
|
338
|
-
}
|
|
339
|
-
if (args.choice === "approve_all") {
|
|
340
|
-
if (p.status === "lift") {
|
|
341
|
-
return p.strict_assertion !== undefined
|
|
342
|
-
? { ...base, status: "lift", strict_assertion: p.strict_assertion }
|
|
343
|
-
: { ...base, status: "demote" };
|
|
344
|
-
}
|
|
345
|
-
return { ...base, status: p.status };
|
|
346
|
-
}
|
|
347
|
-
// approve_high_only
|
|
348
|
-
if (p.status === "lift" && p.confidence_signal === "high") {
|
|
349
|
-
return p.strict_assertion !== undefined
|
|
350
|
-
? { ...base, status: "lift", strict_assertion: p.strict_assertion }
|
|
351
|
-
: { ...base, status: "skip" };
|
|
352
|
-
}
|
|
353
|
-
if (p.status === "demote") {
|
|
354
|
-
return { ...base, status: "demote" };
|
|
355
|
-
}
|
|
356
|
-
return { ...base, status: "skip" };
|
|
357
|
-
});
|
|
358
|
-
}
|
|
359
|
-
function renderDialogPrompt(args) {
|
|
360
|
-
const lines = [];
|
|
361
|
-
lines.push(`Refine ${args.decisionId} — ${args.proposals.length} candidate${args.proposals.length === 1 ? "" : "s"}`);
|
|
362
|
-
lines.push(`"${args.subject}"`);
|
|
363
|
-
lines.push("");
|
|
364
|
-
for (const p of args.proposals) {
|
|
365
|
-
const marker = p.status === "lift" && p.confidence_signal === "high"
|
|
366
|
-
? "✅"
|
|
367
|
-
: p.status === "lift"
|
|
368
|
-
? "🟡"
|
|
369
|
-
: p.status === "demote"
|
|
370
|
-
? "🟠"
|
|
371
|
-
: "⚪";
|
|
372
|
-
const rationale = p.rationale.length > RATIONALE_DISPLAY_CAP
|
|
373
|
-
? p.rationale.slice(0, RATIONALE_DISPLAY_CAP) + "…"
|
|
374
|
-
: p.rationale;
|
|
375
|
-
lines.push(`${marker} ${p.candidate_id} [${p.candidate_kind}] ${p.confidence_signal.toUpperCase()} → ${p.status}`);
|
|
376
|
-
lines.push(` ${rationale}`);
|
|
377
|
-
if (p.status === "lift" && p.strict_assertion !== undefined) {
|
|
378
|
-
const preview = JSON.stringify(p.strict_assertion);
|
|
379
|
-
const previewClipped = preview.length > 160 ? preview.slice(0, 160) + "…" : preview;
|
|
380
|
-
lines.push(` shape: ${previewClipped}`);
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
lines.push("");
|
|
384
|
-
const recLifts = args.proposals.filter((p) => p.status === "lift").length;
|
|
385
|
-
const recDemotes = args.proposals.filter((p) => p.status === "demote").length;
|
|
386
|
-
const recSkips = args.proposals.filter((p) => p.status === "skip").length;
|
|
387
|
-
const highOnly = args.proposals.filter((p) => p.status === "lift" && p.confidence_signal === "high").length;
|
|
388
|
-
lines.push(`Recs: lift=${recLifts}, demote=${recDemotes}, skip=${recSkips}. HIGH-only lifts=${highOnly}.`);
|
|
389
|
-
let body = lines.join("\n");
|
|
390
|
-
if (body.length > DIALOG_PROMPT_CHAR_CAP) {
|
|
391
|
-
body = body.slice(0, DIALOG_PROMPT_CHAR_CAP - 16) + "\n…[truncated]";
|
|
392
|
-
}
|
|
393
|
-
return body;
|
|
394
|
-
}
|
|
395
|
-
function emptyResult(decisionId, choice) {
|
|
396
|
-
return {
|
|
397
|
-
decision_id: decisionId,
|
|
398
|
-
proposals: [],
|
|
399
|
-
operator_choice: choice,
|
|
400
|
-
lifted_count: 0,
|
|
401
|
-
demoted_count: 0,
|
|
402
|
-
skipped_count: 0,
|
|
403
|
-
};
|
|
404
|
-
}
|
|
405
|
-
function isRefinerOutput(value) {
|
|
406
|
-
if (typeof value !== "object" || value === null)
|
|
407
|
-
return false;
|
|
408
|
-
const v = value;
|
|
409
|
-
if (!Array.isArray(v["proposals"]))
|
|
410
|
-
return false;
|
|
411
|
-
for (const p of v["proposals"]) {
|
|
412
|
-
if (typeof p !== "object" || p === null)
|
|
413
|
-
return false;
|
|
414
|
-
const pp = p;
|
|
415
|
-
if (typeof pp["candidate_id"] !== "string")
|
|
416
|
-
return false;
|
|
417
|
-
if (typeof pp["candidate_kind"] !== "string")
|
|
418
|
-
return false;
|
|
419
|
-
if (pp["status"] !== "lift" &&
|
|
420
|
-
pp["status"] !== "demote" &&
|
|
421
|
-
pp["status"] !== "skip") {
|
|
422
|
-
return false;
|
|
423
|
-
}
|
|
424
|
-
if (pp["confidence_signal"] !== "high" &&
|
|
425
|
-
pp["confidence_signal"] !== "medium" &&
|
|
426
|
-
pp["confidence_signal"] !== "low") {
|
|
427
|
-
return false;
|
|
428
|
-
}
|
|
429
|
-
if (typeof pp["rationale"] !== "string")
|
|
430
|
-
return false;
|
|
431
|
-
if (pp["strict_assertion"] !== undefined &&
|
|
432
|
-
(typeof pp["strict_assertion"] !== "object" ||
|
|
433
|
-
pp["strict_assertion"] === null)) {
|
|
434
|
-
return false;
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
return true;
|
|
438
|
-
}
|
|
439
|
-
//# sourceMappingURL=refinement.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"refinement.js","sourceRoot":"","sources":["../../src/decision-capture/refinement.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EACL,iCAAiC,EACjC,iCAAiC,GAClC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,iCAAiC,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,EAAE,0BAA0B,EAAoB,MAAM,aAAa,CAAC;AAS3E,MAAM,GAAG,GAAG,MAAM,CAAC,6BAA6B,CAAC,CAAC;AAElD,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAClC,4EAA4E;AAC5E,MAAM,sBAAsB,GAAG,KAAK,CAAC;AAErC,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAC/B,MAAM,wBAAwB,GAAG,GAAG,CAAC;AACrC,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAC9B,MAAM,WAAW,GAAG,GAAG,CAAC;AAQx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