@proposit/proposit-core 1.2.0 → 1.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/extensions/argument-ingestion/index.d.ts +4 -0
- package/dist/extensions/argument-ingestion/index.d.ts.map +1 -1
- package/dist/extensions/argument-ingestion/index.js +9 -4
- package/dist/extensions/argument-ingestion/index.js.map +1 -1
- package/dist/extensions/argument-ingestion/shared/finalize-response-v2.d.ts +17 -0
- package/dist/extensions/argument-ingestion/shared/finalize-response-v2.d.ts.map +1 -0
- package/dist/extensions/argument-ingestion/shared/finalize-response-v2.js +185 -0
- package/dist/extensions/argument-ingestion/shared/finalize-response-v2.js.map +1 -0
- package/dist/extensions/argument-ingestion/stages/axiom-indicator-detection.d.ts +6 -0
- package/dist/extensions/argument-ingestion/stages/axiom-indicator-detection.d.ts.map +1 -0
- package/dist/extensions/argument-ingestion/stages/axiom-indicator-detection.js +42 -0
- package/dist/extensions/argument-ingestion/stages/axiom-indicator-detection.js.map +1 -0
- package/dist/extensions/argument-ingestion/stages/citation-source-detection.d.ts +6 -0
- package/dist/extensions/argument-ingestion/stages/citation-source-detection.d.ts.map +1 -0
- package/dist/extensions/argument-ingestion/stages/citation-source-detection.js +42 -0
- package/dist/extensions/argument-ingestion/stages/citation-source-detection.js.map +1 -0
- package/dist/extensions/argument-ingestion/stages/claim-canonicalization.d.ts +15 -0
- package/dist/extensions/argument-ingestion/stages/claim-canonicalization.d.ts.map +1 -0
- package/dist/extensions/argument-ingestion/stages/claim-canonicalization.js +148 -0
- package/dist/extensions/argument-ingestion/stages/claim-canonicalization.js.map +1 -0
- package/dist/extensions/argument-ingestion/stages/claim-mention-extraction.d.ts +6 -0
- package/dist/extensions/argument-ingestion/stages/claim-mention-extraction.d.ts.map +1 -0
- package/dist/extensions/argument-ingestion/stages/claim-mention-extraction.js +38 -0
- package/dist/extensions/argument-ingestion/stages/claim-mention-extraction.js.map +1 -0
- package/dist/extensions/argument-ingestion/stages/claim-reference-validation.d.ts +37 -0
- package/dist/extensions/argument-ingestion/stages/claim-reference-validation.d.ts.map +1 -0
- package/dist/extensions/argument-ingestion/stages/claim-reference-validation.js +108 -0
- package/dist/extensions/argument-ingestion/stages/claim-reference-validation.js.map +1 -0
- package/dist/extensions/argument-ingestion/stages/claim-type-classification.d.ts +6 -0
- package/dist/extensions/argument-ingestion/stages/claim-type-classification.d.ts.map +1 -0
- package/dist/extensions/argument-ingestion/stages/claim-type-classification.js +67 -0
- package/dist/extensions/argument-ingestion/stages/claim-type-classification.js.map +1 -0
- package/dist/extensions/argument-ingestion/stages/conclusion-selection.d.ts +20 -0
- package/dist/extensions/argument-ingestion/stages/conclusion-selection.d.ts.map +1 -0
- package/dist/extensions/argument-ingestion/stages/conclusion-selection.js +94 -0
- package/dist/extensions/argument-ingestion/stages/conclusion-selection.js.map +1 -0
- package/dist/extensions/argument-ingestion/stages/formula-compilation.d.ts +27 -0
- package/dist/extensions/argument-ingestion/stages/formula-compilation.d.ts.map +1 -0
- package/dist/extensions/argument-ingestion/stages/formula-compilation.js +175 -0
- package/dist/extensions/argument-ingestion/stages/formula-compilation.js.map +1 -0
- package/dist/extensions/argument-ingestion/stages/formula-validation.d.ts +19 -0
- package/dist/extensions/argument-ingestion/stages/formula-validation.d.ts.map +1 -0
- package/dist/extensions/argument-ingestion/stages/formula-validation.js +101 -0
- package/dist/extensions/argument-ingestion/stages/formula-validation.js.map +1 -0
- package/dist/extensions/argument-ingestion/stages/index.d.ts +15 -0
- package/dist/extensions/argument-ingestion/stages/index.d.ts.map +1 -0
- package/dist/extensions/argument-ingestion/stages/index.js +16 -0
- package/dist/extensions/argument-ingestion/stages/index.js.map +1 -0
- package/dist/extensions/argument-ingestion/stages/relation-extraction.d.ts +7 -0
- package/dist/extensions/argument-ingestion/stages/relation-extraction.d.ts.map +1 -0
- package/dist/extensions/argument-ingestion/stages/relation-extraction.js +77 -0
- package/dist/extensions/argument-ingestion/stages/relation-extraction.js.map +1 -0
- package/dist/extensions/argument-ingestion/stages/schemas.d.ts +161 -0
- package/dist/extensions/argument-ingestion/stages/schemas.d.ts.map +1 -0
- package/dist/extensions/argument-ingestion/stages/schemas.js +218 -0
- package/dist/extensions/argument-ingestion/stages/schemas.js.map +1 -0
- package/dist/extensions/argument-ingestion/stages/segmentation.d.ts +6 -0
- package/dist/extensions/argument-ingestion/stages/segmentation.d.ts.map +1 -0
- package/dist/extensions/argument-ingestion/stages/segmentation.js +37 -0
- package/dist/extensions/argument-ingestion/stages/segmentation.js.map +1 -0
- package/dist/extensions/argument-ingestion/stages/variable-assignment.d.ts +15 -0
- package/dist/extensions/argument-ingestion/stages/variable-assignment.d.ts.map +1 -0
- package/dist/extensions/argument-ingestion/stages/variable-assignment.js +84 -0
- package/dist/extensions/argument-ingestion/stages/variable-assignment.js.map +1 -0
- package/dist/extensions/argument-ingestion/v2-multi-stage.d.ts +15 -0
- package/dist/extensions/argument-ingestion/v2-multi-stage.d.ts.map +1 -0
- package/dist/extensions/argument-ingestion/v2-multi-stage.js +91 -0
- package/dist/extensions/argument-ingestion/v2-multi-stage.js.map +1 -0
- package/dist/lib/index.d.ts +2 -2
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +1 -1
- package/dist/lib/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// `claim-mention-extraction` — extracts every textual mention of a
|
|
2
|
+
// claim (a proposition the author makes) from each segment. Mentions
|
|
3
|
+
// are NOT deduplicated at this stage; `claim-canonicalization` does
|
|
4
|
+
// the dedupe/merge work. Producing mentions per-segment keeps this
|
|
5
|
+
// stage cheap + parallelizable; the dedupe stage gets the full
|
|
6
|
+
// mention list as context.
|
|
7
|
+
import { STAGE_IDS, ClaimMentionExtractionOutputSchema, } from "./schemas.js";
|
|
8
|
+
import { llmStage } from "../../../lib/pipelines/stage-helpers.js";
|
|
9
|
+
export const CLAIM_MENTION_EXTRACTION_MODEL = "gpt-5.4";
|
|
10
|
+
export const CLAIM_MENTION_EXTRACTION_SYSTEM_PROMPT = `You extract textual "claim mentions" from segments of an argument. A mention is any contiguous span of text that asserts a proposition the author is making — a sentence-or-clause-sized chunk that a reader would read as a single assertion.
|
|
11
|
+
|
|
12
|
+
Return an object with a single key \`mentions\` whose value is the array of extracted mentions. For each mention emit:
|
|
13
|
+
- a fresh "mentionId" (m1, m2, ...; unique across all segments)
|
|
14
|
+
- the "segmentId" the mention belongs to
|
|
15
|
+
- the verbatim "text" of the mention (copy from the input — do not rewrite)
|
|
16
|
+
- the character "span" (an object with "start" inclusive, "end" exclusive) relative to the SEGMENT'S TEXT (not the original input)
|
|
17
|
+
|
|
18
|
+
A single segment can produce multiple mentions when it asserts multiple things. Most segments produce one mention. Do NOT deduplicate — if the same proposition is reasserted in a later segment, emit it as a separate mention there too. Do NOT classify the mention. Do NOT include connectives, hedges, or discourse markers in the span when they are not part of the asserted proposition.
|
|
19
|
+
|
|
20
|
+
If a segment is purely a discourse marker (e.g., "Therefore," or "Moreover,"), emit no mention for it. If there are no mentions at all, return \`{ "mentions": [] }\`.`;
|
|
21
|
+
function buildPrompt(ctx) {
|
|
22
|
+
const segmentation = ctx.get(STAGE_IDS.segmentation);
|
|
23
|
+
const segments = segmentation?.segments ?? [];
|
|
24
|
+
const renderedSegments = segments
|
|
25
|
+
.map((s) => `[${s.segmentId}] ${JSON.stringify(s.text)}`)
|
|
26
|
+
.join("\n");
|
|
27
|
+
const markedSystem = `<!-- stage-id: ${STAGE_IDS.claimMentionExtraction} -->\n${CLAIM_MENTION_EXTRACTION_SYSTEM_PROMPT}`;
|
|
28
|
+
const user = `Segments:\n\n${renderedSegments}\n\nExtract every claim mention.`;
|
|
29
|
+
return { system: markedSystem, user };
|
|
30
|
+
}
|
|
31
|
+
export const claimMentionExtractionStage = llmStage({
|
|
32
|
+
id: STAGE_IDS.claimMentionExtraction,
|
|
33
|
+
dependsOn: [STAGE_IDS.segmentation],
|
|
34
|
+
outputSchema: ClaimMentionExtractionOutputSchema,
|
|
35
|
+
model: CLAIM_MENTION_EXTRACTION_MODEL,
|
|
36
|
+
buildPrompt,
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=claim-mention-extraction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claim-mention-extraction.js","sourceRoot":"","sources":["../../../../src/extensions/argument-ingestion/stages/claim-mention-extraction.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,qEAAqE;AACrE,oEAAoE;AACpE,mEAAmE;AACnE,+DAA+D;AAC/D,2BAA2B;AAE3B,OAAO,EACH,SAAS,EACT,kCAAkC,GAGrC,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,QAAQ,EAAE,MAAM,yCAAyC,CAAA;AAGlE,MAAM,CAAC,MAAM,8BAA8B,GAAG,SAAS,CAAA;AAEvD,MAAM,CAAC,MAAM,sCAAsC,GAAG;;;;;;;;;;uKAUiH,CAAA;AAEvK,SAAS,WAAW,CAAC,GAAkB;IACnC,MAAM,YAAY,GAAG,GAAG,CAAC,GAAG,CAAsB,SAAS,CAAC,YAAY,CAAC,CAAA;IACzE,MAAM,QAAQ,GAAG,YAAY,EAAE,QAAQ,IAAI,EAAE,CAAA;IAC7C,MAAM,gBAAgB,GAAG,QAAQ;SAC5B,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,SAAS,KAAK,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;SACxD,IAAI,CAAC,IAAI,CAAC,CAAA;IACf,MAAM,YAAY,GAAG,kBAAkB,SAAS,CAAC,sBAAsB,SAAS,sCAAsC,EAAE,CAAA;IACxH,MAAM,IAAI,GAAG,gBAAgB,gBAAgB,kCAAkC,CAAA;IAC/E,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,CAAA;AACzC,CAAC;AAED,MAAM,CAAC,MAAM,2BAA2B,GACpC,QAAQ,CAAgC;IACpC,EAAE,EAAE,SAAS,CAAC,sBAAsB;IACpC,SAAS,EAAE,CAAC,SAAS,CAAC,YAAY,CAAC;IACnC,YAAY,EAAE,kCAAkC;IAChD,KAAK,EAAE,8BAA8B;IACrC,WAAW;CACd,CAAC,CAAA"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type TClaimCanonicalizationOutput, type TValidationStageOutput } from "./schemas.js";
|
|
2
|
+
import type { TStage } from "../../../lib/pipelines/types.js";
|
|
3
|
+
export declare const CLAIM_REFERENCE_FAILURE_CODES: {
|
|
4
|
+
readonly miniIdCollision: "CLAIM_MINIID_COLLISION";
|
|
5
|
+
readonly danglingMapping: "CLAIM_MENTION_MAPPING_DANGLING";
|
|
6
|
+
readonly emptyMentionId: "CLAIM_MENTION_ID_EMPTY";
|
|
7
|
+
readonly emptyMentionList: "CLAIM_MENTION_LIST_EMPTY";
|
|
8
|
+
};
|
|
9
|
+
export type TClaimReferenceFailureContext = {
|
|
10
|
+
code: "CLAIM_MINIID_COLLISION";
|
|
11
|
+
claimMiniId: string;
|
|
12
|
+
occurrences: number;
|
|
13
|
+
} | {
|
|
14
|
+
code: "CLAIM_MENTION_MAPPING_DANGLING";
|
|
15
|
+
mentionId: string;
|
|
16
|
+
unknownClaimMiniId: string;
|
|
17
|
+
} | {
|
|
18
|
+
code: "CLAIM_MENTION_ID_EMPTY";
|
|
19
|
+
targetClaimMiniId: string;
|
|
20
|
+
} | {
|
|
21
|
+
code: "CLAIM_MENTION_LIST_EMPTY";
|
|
22
|
+
claimMiniId: string;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Pure helper exposed for direct testing. Returns the list of
|
|
26
|
+
* failures the stage will emit; the stage wrapper also calls
|
|
27
|
+
* `ctx.addFailure` on each.
|
|
28
|
+
*/
|
|
29
|
+
export declare function validateClaimReferences(canon: TClaimCanonicalizationOutput): {
|
|
30
|
+
failures: {
|
|
31
|
+
code: string;
|
|
32
|
+
message: string;
|
|
33
|
+
context: Record<string, unknown>;
|
|
34
|
+
}[];
|
|
35
|
+
};
|
|
36
|
+
export declare const claimReferenceValidationStage: TStage<TValidationStageOutput>;
|
|
37
|
+
//# sourceMappingURL=claim-reference-validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claim-reference-validation.d.ts","sourceRoot":"","sources":["../../../../src/extensions/argument-ingestion/stages/claim-reference-validation.ts"],"names":[],"mappings":"AAiBA,OAAO,EAGH,KAAK,4BAA4B,EACjC,KAAK,sBAAsB,EAC9B,MAAM,cAAc,CAAA;AAErB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAA;AAE7D,eAAO,MAAM,6BAA6B;;;;;CAKhC,CAAA;AAEV,MAAM,MAAM,6BAA6B,GACnC;IACI,IAAI,EAAE,wBAAwB,CAAA;IAC9B,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;CACtB,GACD;IACI,IAAI,EAAE,gCAAgC,CAAA;IACtC,SAAS,EAAE,MAAM,CAAA;IACjB,kBAAkB,EAAE,MAAM,CAAA;CAC7B,GACD;IAAE,IAAI,EAAE,wBAAwB,CAAC;IAAC,iBAAiB,EAAE,MAAM,CAAA;CAAE,GAC7D;IAAE,IAAI,EAAE,0BAA0B,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAAA;AAE/D;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,4BAA4B,GAAG;IAC1E,QAAQ,EAAE;QACN,IAAI,EAAE,MAAM,CAAA;QACZ,OAAO,EAAE,MAAM,CAAA;QACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KACnC,EAAE,CAAA;CACN,CAmEA;AAED,eAAO,MAAM,6BAA6B,EAAE,MAAM,CAAC,sBAAsB,CAyBnE,CAAA"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
// `claim-reference-validation` — deterministic stage that audits the
|
|
2
|
+
// `claim-canonicalization` output for internal consistency.
|
|
3
|
+
//
|
|
4
|
+
// Emits a `ProcessingFailure` (via `ctx.addFailure`) for each of:
|
|
5
|
+
// - **miniId collision** — two canonical claims share the same
|
|
6
|
+
// `miniId`.
|
|
7
|
+
// - **dangling mapping** — `mentionToClaim` references a `miniId`
|
|
8
|
+
// that isn't in `canonicalClaims`.
|
|
9
|
+
// - **empty mention id** — `mentionToClaim` key is empty/whitespace.
|
|
10
|
+
// - **empty mention list on a claim** — a claim's `mentionIds` is
|
|
11
|
+
// empty (a canonicalizer-internal bug; every canonical claim
|
|
12
|
+
// should map back to ≥1 mention).
|
|
13
|
+
//
|
|
14
|
+
// Doesn't gate downstream (failures are informational; the stage's
|
|
15
|
+
// return value mirrors the emitted failures for any downstream stage
|
|
16
|
+
// that wants to consult them, but most don't).
|
|
17
|
+
import { STAGE_IDS, ValidationStageOutputSchema, } from "./schemas.js";
|
|
18
|
+
import { deterministicStage } from "../../../lib/pipelines/stage-helpers.js";
|
|
19
|
+
export const CLAIM_REFERENCE_FAILURE_CODES = {
|
|
20
|
+
miniIdCollision: "CLAIM_MINIID_COLLISION",
|
|
21
|
+
danglingMapping: "CLAIM_MENTION_MAPPING_DANGLING",
|
|
22
|
+
emptyMentionId: "CLAIM_MENTION_ID_EMPTY",
|
|
23
|
+
emptyMentionList: "CLAIM_MENTION_LIST_EMPTY",
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Pure helper exposed for direct testing. Returns the list of
|
|
27
|
+
* failures the stage will emit; the stage wrapper also calls
|
|
28
|
+
* `ctx.addFailure` on each.
|
|
29
|
+
*/
|
|
30
|
+
export function validateClaimReferences(canon) {
|
|
31
|
+
const failures = [];
|
|
32
|
+
// 1. miniId collisions.
|
|
33
|
+
const miniIdCounts = new Map();
|
|
34
|
+
for (const claim of canon.canonicalClaims) {
|
|
35
|
+
miniIdCounts.set(claim.miniId, (miniIdCounts.get(claim.miniId) ?? 0) + 1);
|
|
36
|
+
}
|
|
37
|
+
for (const [miniId, count] of miniIdCounts) {
|
|
38
|
+
if (count > 1) {
|
|
39
|
+
failures.push({
|
|
40
|
+
code: CLAIM_REFERENCE_FAILURE_CODES.miniIdCollision,
|
|
41
|
+
message: `Canonical claim miniId "${miniId}" appears ${String(count)} times; miniIds must be unique within a single pipeline run.`,
|
|
42
|
+
context: { claimMiniId: miniId, occurrences: count },
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const knownMiniIds = new Set(canon.canonicalClaims.map((c) => c.miniId));
|
|
47
|
+
// 2. mentionToClaim dangling references + empty mention ids.
|
|
48
|
+
// mentionToClaim is now a list of { mentionId, claimMiniId }
|
|
49
|
+
// entries (lambda-fold 4 — OpenAI strict-mode doesn't accept
|
|
50
|
+
// Record-shaped maps with arbitrary string keys).
|
|
51
|
+
for (const entry of canon.mentionToClaim) {
|
|
52
|
+
const { mentionId, claimMiniId } = entry;
|
|
53
|
+
if (mentionId.trim().length === 0) {
|
|
54
|
+
failures.push({
|
|
55
|
+
code: CLAIM_REFERENCE_FAILURE_CODES.emptyMentionId,
|
|
56
|
+
message: `mentionToClaim has an empty/whitespace mention id targeting claim "${claimMiniId}".`,
|
|
57
|
+
context: { targetClaimMiniId: claimMiniId },
|
|
58
|
+
});
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (!knownMiniIds.has(claimMiniId)) {
|
|
62
|
+
failures.push({
|
|
63
|
+
code: CLAIM_REFERENCE_FAILURE_CODES.danglingMapping,
|
|
64
|
+
message: `mentionToClaim entry "${mentionId}" points at claim "${claimMiniId}" which is not in canonicalClaims.`,
|
|
65
|
+
context: {
|
|
66
|
+
mentionId,
|
|
67
|
+
unknownClaimMiniId: claimMiniId,
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
// 3. claims with empty mentionIds.
|
|
73
|
+
for (const claim of canon.canonicalClaims) {
|
|
74
|
+
if (claim.mentionIds.length === 0) {
|
|
75
|
+
failures.push({
|
|
76
|
+
code: CLAIM_REFERENCE_FAILURE_CODES.emptyMentionList,
|
|
77
|
+
message: `Canonical claim "${claim.miniId}" has an empty mentionIds list; every canonical claim must reference at least one mention.`,
|
|
78
|
+
context: { claimMiniId: claim.miniId },
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return { failures };
|
|
83
|
+
}
|
|
84
|
+
export const claimReferenceValidationStage = deterministicStage({
|
|
85
|
+
id: STAGE_IDS.claimReferenceValidation,
|
|
86
|
+
dependsOn: [STAGE_IDS.claimCanonicalization],
|
|
87
|
+
outputSchema: ValidationStageOutputSchema,
|
|
88
|
+
fn: (ctx) => {
|
|
89
|
+
const canon = ctx.get(STAGE_IDS.claimCanonicalization);
|
|
90
|
+
if (!canon)
|
|
91
|
+
return [];
|
|
92
|
+
const { failures } = validateClaimReferences(canon);
|
|
93
|
+
for (const f of failures) {
|
|
94
|
+
ctx.addFailure({
|
|
95
|
+
code: f.code,
|
|
96
|
+
message: f.message,
|
|
97
|
+
severity: "warning",
|
|
98
|
+
context: f.context,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
return failures.map((f) => ({
|
|
102
|
+
code: f.code,
|
|
103
|
+
message: f.message,
|
|
104
|
+
context: f.context,
|
|
105
|
+
}));
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
//# sourceMappingURL=claim-reference-validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claim-reference-validation.js","sourceRoot":"","sources":["../../../../src/extensions/argument-ingestion/stages/claim-reference-validation.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,4DAA4D;AAC5D,EAAE;AACF,kEAAkE;AAClE,iEAAiE;AACjE,gBAAgB;AAChB,oEAAoE;AACpE,uCAAuC;AACvC,uEAAuE;AACvE,oEAAoE;AACpE,iEAAiE;AACjE,sCAAsC;AACtC,EAAE;AACF,mEAAmE;A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AAS,EAAE,CAAC,SAAS,CAAC,qBAAqB,CAAC;IAC5C,YAAY,EAAE,2BAA2B;IACzC,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE;QACR,MAAM,KAAK,GAAG,GAAG,CAAC,GAAG,CACjB,SAAS,CAAC,qBAAqB,CAClC,CAAA;QACD,IAAI,CAAC,KAAK;YAAE,OAAO,EAAE,CAAA;QACrB,MAAM,EAAE,QAAQ,EAAE,GAAG,uBAAuB,CAAC,KAAK,CAAC,CAAA;QACnD,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;YACvB,GAAG,CAAC,UAAU,CAAC;gBACX,IAAI,EAAE,CAAC,CAAC,IAAI;gBACZ,OAAO,EAAE,CAAC,CAAC,OAAO;gBAClB,QAAQ,EAAE,SAAS;gBACnB,OAAO,EAAE,CAAC,CAAC,OAAO;aACrB,CAAC,CAAA;QACN,CAAC;QACD,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACxB,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,OAAO,EAAE,CAAC,CAAC,OAAO;YAClB,OAAO,EAAE,CAAC,CAAC,OAAO;SACrB,CAAC,CAAC,CAAA;IACP,CAAC;CACJ,CAAC,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type TClaimTypeClassificationOutput } from "./schemas.js";
|
|
2
|
+
import type { TStage } from "../../../lib/pipelines/types.js";
|
|
3
|
+
export declare const CLAIM_TYPE_CLASSIFICATION_MODEL = "gpt-5.4";
|
|
4
|
+
export declare const CLAIM_TYPE_CLASSIFICATION_SYSTEM_PROMPT = "You confirm or revise the type of each canonical claim in an argument-ingestion pipeline.\n\nReturn an object with a single key `classifications` whose value is an array of per-claim entries. For each canonical claim you receive (id, the canonicalizer's draft `type`, and the claim's body/title/url/axiom fields), emit one entry with:\n- `miniId` \u2014 the canonical claim's miniId (copy verbatim)\n- `type` \u2014 one of \"normal\", \"citation\", \"axiomatic\"\n- `sourceString` \u2014 populate when type is \"citation\" with the source label (or url) the claim is built on; null otherwise\n\nUse the supplied detected citation sources + axiom indicators as evidence. Override the canonicalizer's draft only when the evidence clearly contradicts it. The default is to confirm the draft. Be conservative \u2014 a wrong override here cascades into wrong support edges downstream.\n\nEvery input claim must appear in `classifications` exactly once.\n\n## Type rules\n\n- `\"normal\"` \u2014 primary reasoning content; the default.\n- `\"citation\"` \u2014 content is \"the cited source says/shows X\" AND a citation source covers the claim. The claim's title/body summarizes what the source asserts; the URL (when present) names the source.\n- `\"axiomatic\"` \u2014 content is invoked as self-evidently true AND an axiom indicator (e.g. \"by definition\") covers or precedes the claim.";
|
|
5
|
+
export declare const claimTypeClassificationStage: TStage<TClaimTypeClassificationOutput>;
|
|
6
|
+
//# sourceMappingURL=claim-type-classification.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claim-type-classification.d.ts","sourceRoot":"","sources":["../../../../src/extensions/argument-ingestion/stages/claim-type-classification.ts"],"names":[],"mappings":"AAOA,OAAO,EAMH,KAAK,8BAA8B,EACtC,MAAM,cAAc,CAAA;AAGrB,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,iCAAiC,CAAA;AAE5E,eAAO,MAAM,+BAA+B,YAAY,CAAA;AAExD,eAAO,MAAM,uCAAuC,82CAesF,CAAA;AAqD1I,eAAO,MAAM,4BAA4B,EAAE,MAAM,CAAC,8BAA8B,CAW1E,CAAA"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// `claim-type-classification` — refines or confirms the canonicalizer's
|
|
2
|
+
// per-claim `type` field. The canonicalizer already drafted a type
|
|
3
|
+
// based on whether a citation or axiom indicator covered the claim;
|
|
4
|
+
// this stage is a second pass that catches mis-classifications (e.g.
|
|
5
|
+
// a claim the canonicalizer marked "normal" that actually belongs to
|
|
6
|
+
// "citation" because the source's content equals the claim's content).
|
|
7
|
+
import { STAGE_IDS, ClaimTypeClassificationOutputSchema, } from "./schemas.js";
|
|
8
|
+
import { llmStage } from "../../../lib/pipelines/stage-helpers.js";
|
|
9
|
+
import { optional } from "../../../lib/pipelines/types.js";
|
|
10
|
+
export const CLAIM_TYPE_CLASSIFICATION_MODEL = "gpt-5.4";
|
|
11
|
+
export const CLAIM_TYPE_CLASSIFICATION_SYSTEM_PROMPT = `You confirm or revise the type of each canonical claim in an argument-ingestion pipeline.
|
|
12
|
+
|
|
13
|
+
Return an object with a single key \`classifications\` whose value is an array of per-claim entries. For each canonical claim you receive (id, the canonicalizer's draft \`type\`, and the claim's body/title/url/axiom fields), emit one entry with:
|
|
14
|
+
- \`miniId\` — the canonical claim's miniId (copy verbatim)
|
|
15
|
+
- \`type\` — one of "normal", "citation", "axiomatic"
|
|
16
|
+
- \`sourceString\` — populate when type is "citation" with the source label (or url) the claim is built on; null otherwise
|
|
17
|
+
|
|
18
|
+
Use the supplied detected citation sources + axiom indicators as evidence. Override the canonicalizer's draft only when the evidence clearly contradicts it. The default is to confirm the draft. Be conservative — a wrong override here cascades into wrong support edges downstream.
|
|
19
|
+
|
|
20
|
+
Every input claim must appear in \`classifications\` exactly once.
|
|
21
|
+
|
|
22
|
+
## Type rules
|
|
23
|
+
|
|
24
|
+
- \`"normal"\` — primary reasoning content; the default.
|
|
25
|
+
- \`"citation"\` — content is "the cited source says/shows X" AND a citation source covers the claim. The claim's title/body summarizes what the source asserts; the URL (when present) names the source.
|
|
26
|
+
- \`"axiomatic"\` — content is invoked as self-evidently true AND an axiom indicator (e.g. "by definition") covers or precedes the claim.`;
|
|
27
|
+
function buildPrompt(ctx) {
|
|
28
|
+
const canon = ctx.get(STAGE_IDS.claimCanonicalization);
|
|
29
|
+
const citationEnvelope = ctx.get(STAGE_IDS.citationSourceDetection);
|
|
30
|
+
const citations = citationEnvelope?.sources ?? [];
|
|
31
|
+
const axiomEnvelope = ctx.get(STAGE_IDS.axiomIndicatorDetection);
|
|
32
|
+
const axioms = axiomEnvelope?.axioms ?? [];
|
|
33
|
+
const claimLines = (canon?.canonicalClaims ?? [])
|
|
34
|
+
.map((c) => ` [${c.miniId}] type=${c.type} suggestedSymbol=${c.suggestedSymbol} fields=${JSON.stringify({
|
|
35
|
+
...c,
|
|
36
|
+
miniId: undefined,
|
|
37
|
+
mentionIds: undefined,
|
|
38
|
+
suggestedSymbol: undefined,
|
|
39
|
+
type: undefined,
|
|
40
|
+
})}`)
|
|
41
|
+
.join("\n");
|
|
42
|
+
const citationLines = citations.length > 0
|
|
43
|
+
? citations
|
|
44
|
+
.map((c) => ` [${c.sourceId} @ ${c.segmentIds.join(",")}] ${JSON.stringify(c.sourceString)}${c.url ? ` (url: ${c.url})` : ""}`)
|
|
45
|
+
.join("\n")
|
|
46
|
+
: " (none)";
|
|
47
|
+
const axiomLines = axioms.length > 0
|
|
48
|
+
? axioms
|
|
49
|
+
.map((a) => ` [${a.axiomId} @ ${a.segmentIds.join(",")}] ${JSON.stringify(a.indicator)}`)
|
|
50
|
+
.join("\n")
|
|
51
|
+
: " (none)";
|
|
52
|
+
const markedSystem = `<!-- stage-id: ${STAGE_IDS.claimTypeClassification} -->\n${CLAIM_TYPE_CLASSIFICATION_SYSTEM_PROMPT}`;
|
|
53
|
+
const user = `Canonical claims (with the canonicalizer's draft type):\n${claimLines}\n\nDetected citation sources:\n${citationLines}\n\nDetected axiom indicators:\n${axiomLines}\n\nEmit the per-claim type map.`;
|
|
54
|
+
return { system: markedSystem, user };
|
|
55
|
+
}
|
|
56
|
+
export const claimTypeClassificationStage = llmStage({
|
|
57
|
+
id: STAGE_IDS.claimTypeClassification,
|
|
58
|
+
dependsOn: [
|
|
59
|
+
STAGE_IDS.claimCanonicalization,
|
|
60
|
+
optional(STAGE_IDS.citationSourceDetection),
|
|
61
|
+
optional(STAGE_IDS.axiomIndicatorDetection),
|
|
62
|
+
],
|
|
63
|
+
outputSchema: ClaimTypeClassificationOutputSchema,
|
|
64
|
+
model: CLAIM_TYPE_CLASSIFICATION_MODEL,
|
|
65
|
+
buildPrompt,
|
|
66
|
+
});
|
|
67
|
+
//# sourceMappingURL=claim-type-classification.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claim-type-classification.js","sourceRoot":"","sources":["../../../../src/extensions/argument-ingestion/stages/claim-type-classification.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,mEAAmE;AACnE,oEAAoE;AACpE,qEAAqE;AACrE,qEAAqE;AACrE,uEAAuE;AAEvE,OAAO,EACH,SAAS,EACT,mCAAmC,GAKtC,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,QAAQ,EAAE,MAAM,yCAAyC,CAAA;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAA;AAG1D,MAAM,CAAC,MAAM,+BAA+B,GAAG,SAAS,CAAA;AAExD,MAAM,CAAC,MAAM,uCAAuC,GAAG;;;;;;;;;;;;;;;0IAemF,CAAA;AAE1I,SAAS,WAAW,CAAC,GAAkB;IACnC,MAAM,KAAK,GAAG,GAAG,CAAC,GAAG,CACjB,SAAS,CAAC,qBAAqB,CAClC,CAAA;IACD,MAAM,gBAAgB,GAAG,GAAG,CAAC,GAAG,CAC5B,SAAS,CAAC,uBAAuB,CACpC,CAAA;IACD,MAAM,SAAS,GAAG,gBAAgB,EAAE,OAAO,IAAI,EAAE,CAAA;IACjD,MAAM,aAAa,GAAG,GAAG,CAAC,GAAG,CACzB,SAAS,CAAC,uBAAuB,CACpC,CAAA;IACD,MAAM,MAAM,GAAG,aAAa,EAAE,MAAM,IAAI,EAAE,CAAA;IAE1C,MAAM,UAAU,GAAG,CAAC,KAAK,EAAE,eAAe,IAAI,EAAE,CAAC;SAC5C,GAAG,CACA,CAAC,CAAC,EAAE,EAAE,CACF,MAAM,CAAC,CAAC,MAAM,UAAU,CAAC,CAAC,IAAI,oBAAoB,CAAC,CAAC,eAAe,WAAW,IAAI,CAAC,SAAS,CACxF;QACI,GAAG,CAAC;QACJ,MAAM,EAAE,SAAS;QACjB,UAAU,EAAE,SA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/B,QAAQ,CAAC,SAAS,CAAC,uBAAuB,CAAC;QAC3C,QAAQ,CAAC,SAAS,CAAC,uBAAuB,CAAC;KAC9C;IACD,YAAY,EAAE,mCAAmC;IACjD,KAAK,EAAE,+BAA+B;IACtC,WAAW;CACd,CAAC,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type TConclusionSelectionOutput } from "./schemas.js";
|
|
2
|
+
import type { TStage } from "../../../lib/pipelines/types.js";
|
|
3
|
+
export declare const CONCLUSION_SELECTION_MODEL = "gpt-5.5";
|
|
4
|
+
export declare const CONCLUSION_SELECTION_REASONING: "minimal" | "low" | "medium" | "high";
|
|
5
|
+
export declare const CONCLUSION_SELECTION_NO_CONCLUSION_FAILURE_CODE = "NO_SINGLE_CONCLUSION";
|
|
6
|
+
export declare const CONCLUSION_SELECTION_SYSTEM_PROMPT = "You select the single conclusion claim of an argument from the canonical claim set and the relation graph.\n\nYou receive:\n- the per-claim type map (normal / citation / axiomatic)\n- the support relation graph from `relation-extraction`\n\nEmit:\n- `conclusionMiniId` \u2014 the canonical claim miniId of the conclusion, OR `null` when no single claim is clearly the conclusion\n- `rationale` \u2014 a one-sentence explanation of your pick (or your inability to pick one)\n\n## Selection rules\n\n1. The conclusion is the claim that no other claim is meant to support but is itself the terminus of one or more support edges. In a clean argument it's the \"therefore X\" claim.\n2. If multiple distinct claims are each terminal AND each could plausibly be THE point of the argument (genuinely ambiguous), return null with a rationale naming the contenders.\n3. Citation-typed and axiomatic-typed claims are never conclusions \u2014 they are always sources of support.\n4. If no claim is supported by any relation (a single-statement input), return null; there is no argument to select a conclusion from.\n\nThe default disposition is \"select\"; only return null when ambiguity is genuine. Forcing a wrong choice is worse than admitting \"no single conclusion could be selected\" \u2014 downstream stages handle the null cleanly.";
|
|
7
|
+
/**
|
|
8
|
+
* `conclusionSelectionStage` wraps the inner `llmStage` so that when
|
|
9
|
+
* the LLM returns `conclusionMiniId: null`, the stage emits a
|
|
10
|
+
* `ProcessingFailure` with code `NO_SINGLE_CONCLUSION` via
|
|
11
|
+
* `ctx.addFailure` (spec §7.2 row 10). The stage still completes
|
|
12
|
+
* successfully — the null output flows through `formula-compilation`
|
|
13
|
+
* (which emits `conclusionPremiseMiniId: null`) into `finalize-response-v2`
|
|
14
|
+
* (which assembles `{ argument: null, failureText: "No single
|
|
15
|
+
* conclusion could be selected." }`). The added failure is a
|
|
16
|
+
* UI-rendering hint, not a task-outcome signal; severity is `warning`
|
|
17
|
+
* to match the informational-only role of finalize's failureText path.
|
|
18
|
+
*/
|
|
19
|
+
export declare const conclusionSelectionStage: TStage<TConclusionSelectionOutput>;
|
|
20
|
+
//# sourceMappingURL=conclusion-selection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conclusion-selection.d.ts","sourceRoot":"","sources":["../../../../src/extensions/argument-ingestion/stages/conclusion-selection.ts"],"names":[],"mappings":"AAWA,OAAO,EAIH,KAAK,0BAA0B,EAElC,MAAM,cAAc,CAAA;AAErB,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,iCAAiC,CAAA;AAE5E,eAAO,MAAM,0BAA0B,YAAY,CAAA;AACnD,eAAO,MAAM,8BAA8B,EACrC,SAAS,GACT,KAAK,GACL,QAAQ,GACR,MAAiB,CAAA;AAEvB,eAAO,MAAM,+CAA+C,yBAClC,CAAA;AAE1B,eAAO,MAAM,kCAAkC,szCAiBuK,CAAA;AA2CtN;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,wBAAwB,EAAE,MAAM,CAAC,0BAA0B,CAmBvE,CAAA"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// `conclusion-selection` — picks the single claim that is the
|
|
2
|
+
// argument's conclusion (the proposition the argument is FOR). Returns
|
|
3
|
+
// null when no single conclusion can be selected (multiple distinct
|
|
4
|
+
// conclusions, no clear conclusion at all). The null path drives
|
|
5
|
+
// `formula-compilation.conclusionPremiseMiniId === null` which in
|
|
6
|
+
// turn drives finalize's "argument: null + failureText: 'No single
|
|
7
|
+
// conclusion could be selected.'" per spec §7.5.
|
|
8
|
+
//
|
|
9
|
+
// Per spec §6.4 this is a strong-reasoning stage: gpt-5.5 with
|
|
10
|
+
// reasoning_effort=medium.
|
|
11
|
+
import { STAGE_IDS, ConclusionSelectionOutputSchema, } from "./schemas.js";
|
|
12
|
+
import { llmStage } from "../../../lib/pipelines/stage-helpers.js";
|
|
13
|
+
export const CONCLUSION_SELECTION_MODEL = "gpt-5.5";
|
|
14
|
+
export const CONCLUSION_SELECTION_REASONING = "medium";
|
|
15
|
+
export const CONCLUSION_SELECTION_NO_CONCLUSION_FAILURE_CODE = "NO_SINGLE_CONCLUSION";
|
|
16
|
+
export const CONCLUSION_SELECTION_SYSTEM_PROMPT = `You select the single conclusion claim of an argument from the canonical claim set and the relation graph.
|
|
17
|
+
|
|
18
|
+
You receive:
|
|
19
|
+
- the per-claim type map (normal / citation / axiomatic)
|
|
20
|
+
- the support relation graph from \`relation-extraction\`
|
|
21
|
+
|
|
22
|
+
Emit:
|
|
23
|
+
- \`conclusionMiniId\` — the canonical claim miniId of the conclusion, OR \`null\` when no single claim is clearly the conclusion
|
|
24
|
+
- \`rationale\` — a one-sentence explanation of your pick (or your inability to pick one)
|
|
25
|
+
|
|
26
|
+
## Selection rules
|
|
27
|
+
|
|
28
|
+
1. The conclusion is the claim that no other claim is meant to support but is itself the terminus of one or more support edges. In a clean argument it's the "therefore X" claim.
|
|
29
|
+
2. If multiple distinct claims are each terminal AND each could plausibly be THE point of the argument (genuinely ambiguous), return null with a rationale naming the contenders.
|
|
30
|
+
3. Citation-typed and axiomatic-typed claims are never conclusions — they are always sources of support.
|
|
31
|
+
4. If no claim is supported by any relation (a single-statement input), return null; there is no argument to select a conclusion from.
|
|
32
|
+
|
|
33
|
+
The default disposition is "select"; only return null when ambiguity is genuine. Forcing a wrong choice is worse than admitting "no single conclusion could be selected" — downstream stages handle the null cleanly.`;
|
|
34
|
+
function buildPrompt(ctx) {
|
|
35
|
+
const typeEnvelope = ctx.get(STAGE_IDS.claimTypeClassification);
|
|
36
|
+
const classifications = typeEnvelope?.classifications ?? [];
|
|
37
|
+
const relationEnvelope = ctx.get(STAGE_IDS.relationExtraction);
|
|
38
|
+
const relations = relationEnvelope?.relations ?? [];
|
|
39
|
+
const typeLines = classifications
|
|
40
|
+
.map((entry) => ` [${entry.miniId}] type=${entry.type}`)
|
|
41
|
+
.join("\n");
|
|
42
|
+
const relationLines = relations.length > 0
|
|
43
|
+
? relations
|
|
44
|
+
.map((r) => ` [${r.relationId}] ${r.type}: sources=[${r.sources.join(",")}] target=${r.target}`)
|
|
45
|
+
.join("\n")
|
|
46
|
+
: " (no relations)";
|
|
47
|
+
const markedSystem = `<!-- stage-id: ${STAGE_IDS.conclusionSelection} -->\n${CONCLUSION_SELECTION_SYSTEM_PROMPT}`;
|
|
48
|
+
const user = `Per-claim types:\n${typeLines}\n\nRelations:\n${relationLines}\n\nSelect the conclusion (or return null).`;
|
|
49
|
+
return { system: markedSystem, user };
|
|
50
|
+
}
|
|
51
|
+
// Inner llmStage that actually performs the LLM call.
|
|
52
|
+
const innerStage = llmStage({
|
|
53
|
+
id: STAGE_IDS.conclusionSelection,
|
|
54
|
+
dependsOn: [
|
|
55
|
+
STAGE_IDS.claimTypeClassification,
|
|
56
|
+
STAGE_IDS.relationExtraction,
|
|
57
|
+
],
|
|
58
|
+
outputSchema: ConclusionSelectionOutputSchema,
|
|
59
|
+
model: CONCLUSION_SELECTION_MODEL,
|
|
60
|
+
reasoningEffort: CONCLUSION_SELECTION_REASONING,
|
|
61
|
+
buildPrompt,
|
|
62
|
+
});
|
|
63
|
+
/**
|
|
64
|
+
* `conclusionSelectionStage` wraps the inner `llmStage` so that when
|
|
65
|
+
* the LLM returns `conclusionMiniId: null`, the stage emits a
|
|
66
|
+
* `ProcessingFailure` with code `NO_SINGLE_CONCLUSION` via
|
|
67
|
+
* `ctx.addFailure` (spec §7.2 row 10). The stage still completes
|
|
68
|
+
* successfully — the null output flows through `formula-compilation`
|
|
69
|
+
* (which emits `conclusionPremiseMiniId: null`) into `finalize-response-v2`
|
|
70
|
+
* (which assembles `{ argument: null, failureText: "No single
|
|
71
|
+
* conclusion could be selected." }`). The added failure is a
|
|
72
|
+
* UI-rendering hint, not a task-outcome signal; severity is `warning`
|
|
73
|
+
* to match the informational-only role of finalize's failureText path.
|
|
74
|
+
*/
|
|
75
|
+
export const conclusionSelectionStage = {
|
|
76
|
+
id: innerStage.id,
|
|
77
|
+
dependsOn: innerStage.dependsOn,
|
|
78
|
+
outputSchema: innerStage.outputSchema,
|
|
79
|
+
run: async (ctx) => {
|
|
80
|
+
const output = await innerStage.run(ctx);
|
|
81
|
+
if (output.conclusionMiniId === null) {
|
|
82
|
+
ctx.addFailure({
|
|
83
|
+
code: CONCLUSION_SELECTION_NO_CONCLUSION_FAILURE_CODE,
|
|
84
|
+
message: output.rationale.length > 0
|
|
85
|
+
? output.rationale
|
|
86
|
+
: "No single conclusion could be selected.",
|
|
87
|
+
severity: "warning",
|
|
88
|
+
context: { rationale: output.rationale },
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return output;
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
//# sourceMappingURL=conclusion-selection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conclusion-selection.js","sourceRoot":"","sources":["../../../../src/extensions/argument-ingestion/stages/conclusion-selection.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,uEAAuE;AACvE,oEAAoE;AACpE,iEAAiE;AACjE,kEAAkE;AAClE,mEAAmE;AACnE,iDAAiD;AACjD,EAAE;AACF,+DAA+D;AAC/D,2BAA2B;AAE3B,OAAO,EACH,SAAS,EACT,+BAA+B,GAIlC,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,QAAQ,EAAE,MAAM,yCAAyC,CAAA;AAGlE,MAAM,CAAC,MAAM,0BAA0B,GAAG,SAAS,CAAA;AACnD,MAAM,CA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UAAU,GAAG,QAAQ,CAA6B;IACpD,EAAE,EAAE,SAAS,CAAC,mBAAmB;IACjC,SAAS,EAAE;QACP,SAAS,CAAC,uBAAuB;QACjC,SAAS,CAAC,kBAAkB;KAC/B;IACD,YAAY,EAAE,+BAA+B;IAC7C,KAAK,EAAE,0BAA0B;IACjC,eAAe,EAAE,8BAA8B;IAC/C,WAAW;CACd,CAAC,CAAA;AAEF;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAuC;IACxE,EAAE,EAAE,UAAU,CAAC,EAAE;IACjB,SAAS,EAAE,UAAU,CAAC,SAAS;IAC/B,YAAY,EAAE,UAAU,CAAC,YAAY;IACrC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;QACf,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QACxC,IAAI,MAAM,CAAC,gBAAgB,KAAK,IAAI,EAAE,CAAC;YACnC,GAAG,CAAC,UAAU,CAAC;gBACX,IAAI,EAAE,+CAA+C;gBACrD,OAAO,EACH,MAAM,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC;oBACvB,CAAC,CAAC,MAAM,CAAC,SAAS;oBAClB,CAAC,CAAC,yCAAyC;gBACnD,QAAQ,EAAE,SAAS;gBACnB,OAAO,EAAE,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE;aAC3C,CAAC,CAAA;QACN,CAAC;QACD,OAAO,MAAM,CAAA;IACjB,CAAC;CACJ,CAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type TConclusionSelectionOutput, type TFormulaCompilationOutput, type TRelationExtractionOutput, type TVariableAssignmentOutput } from "./schemas.js";
|
|
2
|
+
import type { TStage } from "../../../lib/pipelines/types.js";
|
|
3
|
+
export declare const FORMULA_COMPILATION_FAILURE_CODES: {
|
|
4
|
+
readonly unresolvedSource: "FORMULA_COMPILATION_SOURCE_UNRESOLVED";
|
|
5
|
+
readonly unresolvedTarget: "FORMULA_COMPILATION_TARGET_UNRESOLVED";
|
|
6
|
+
readonly unresolvedConclusion: "FORMULA_COMPILATION_CONCLUSION_UNRESOLVED";
|
|
7
|
+
readonly emptySources: "FORMULA_COMPILATION_SOURCES_EMPTY";
|
|
8
|
+
};
|
|
9
|
+
export type TCompileFormulasInput = {
|
|
10
|
+
/** Bare relations array (unwrapped from the stage's envelope). */
|
|
11
|
+
relations: TRelationExtractionOutput["relations"];
|
|
12
|
+
conclusion: TConclusionSelectionOutput | undefined;
|
|
13
|
+
variables: TVariableAssignmentOutput;
|
|
14
|
+
generateId: () => string;
|
|
15
|
+
addFailure?: (failure: {
|
|
16
|
+
code: string;
|
|
17
|
+
message: string;
|
|
18
|
+
severity: "warning" | "error";
|
|
19
|
+
context?: Record<string, unknown>;
|
|
20
|
+
}) => void;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Pure helper exposed for direct testing.
|
|
24
|
+
*/
|
|
25
|
+
export declare function compileFormulas(input: TCompileFormulasInput): TFormulaCompilationOutput;
|
|
26
|
+
export declare const formulaCompilationStage: TStage<TFormulaCompilationOutput>;
|
|
27
|
+
//# sourceMappingURL=formula-compilation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formula-compilation.d.ts","sourceRoot":"","sources":["../../../../src/extensions/argument-ingestion/stages/formula-compilation.ts"],"names":[],"mappings":"AAwBA,OAAO,EAGH,KAAK,0BAA0B,EAC/B,KAAK,yBAAyB,EAE9B,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,EACjC,MAAM,cAAc,CAAA;AAErB,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,iCAAiC,CAAA;AAE5E,eAAO,MAAM,iCAAiC;;;;;CAKpC,CAAA;AAEV,MAAM,MAAM,qBAAqB,GAAG;IAChC,kEAAkE;IAClE,SAAS,EAAE,yBAAyB,CAAC,WAAW,CAAC,CAAA;IACjD,UAAU,EAAE,0BAA0B,GAAG,SAAS,CAAA;IAClD,SAAS,EAAE,yBAAyB,CAAA;IACpC,UAAU,EAAE,MAAM,MAAM,CAAA;IACxB,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE;QACnB,IAAI,EAAE,MAAM,CAAA;QACZ,OAAO,EAAE,MAAM,CAAA;QACf,QAAQ,EAAE,SAAS,GAAG,OAAO,CAAA;QAC7B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KACpC,KAAK,IAAI,CAAA;CACb,CAAA;AAyBD;;GAEG;AACH,wBAAgB,eAAe,CAC3B,KAAK,EAAE,qBAAqB,GAC7B,yBAAyB,CAqG3B;AAED,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAAC,yBAAyB,CA8BhE,CAAA"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
// `formula-compilation` — deterministic stage that compiles each
|
|
2
|
+
// `relation-extraction` output into a `parseFormula`-consumable
|
|
3
|
+
// formula string, and mints one dedicated "conclusion premise" whose
|
|
4
|
+
// formula is just the conclusion claim's variable symbol.
|
|
5
|
+
//
|
|
6
|
+
// Compilation rules (spec §7.3):
|
|
7
|
+
// support s → t ⇒ s_symbol IMPLIES t_symbol
|
|
8
|
+
// joint-support s1..sn → t ⇒ (s1 AND s2 AND ...) IMPLIES t_symbol
|
|
9
|
+
// derivation-support s → t ⇒ s_symbol IMPLIES t_symbol
|
|
10
|
+
//
|
|
11
|
+
// The conclusion-premise mapping rule:
|
|
12
|
+
// - When `conclusion-selection.conclusionMiniId` is non-null:
|
|
13
|
+
// exactly one premise is minted with `roleHint: "conclusion"` and
|
|
14
|
+
// `formula: <conclusion claim's variable symbol>`.
|
|
15
|
+
// - When `conclusion-selection.conclusionMiniId` is null OR the
|
|
16
|
+
// conclusion claim has no resolvable variable symbol:
|
|
17
|
+
// `conclusionPremiseMiniId` is null and the conclusion premise is
|
|
18
|
+
// not emitted. The relation premises are still emitted.
|
|
19
|
+
//
|
|
20
|
+
// We emit a `ProcessingFailure` (severity `error`) when a relation's
|
|
21
|
+
// `sources` or `target` cannot be resolved to a variable symbol. The
|
|
22
|
+
// failing relation's premise is dropped from the output (we can't
|
|
23
|
+
// compile it without symbols).
|
|
24
|
+
import { STAGE_IDS, FormulaCompilationOutputSchema, } from "./schemas.js";
|
|
25
|
+
import { deterministicStage } from "../../../lib/pipelines/stage-helpers.js";
|
|
26
|
+
export const FORMULA_COMPILATION_FAILURE_CODES = {
|
|
27
|
+
unresolvedSource: "FORMULA_COMPILATION_SOURCE_UNRESOLVED",
|
|
28
|
+
unresolvedTarget: "FORMULA_COMPILATION_TARGET_UNRESOLVED",
|
|
29
|
+
unresolvedConclusion: "FORMULA_COMPILATION_CONCLUSION_UNRESOLVED",
|
|
30
|
+
emptySources: "FORMULA_COMPILATION_SOURCES_EMPTY",
|
|
31
|
+
};
|
|
32
|
+
function buildClaimToSymbol(variables) {
|
|
33
|
+
const m = new Map();
|
|
34
|
+
for (const v of variables) {
|
|
35
|
+
m.set(v.claimMiniId, v.symbol);
|
|
36
|
+
}
|
|
37
|
+
return m;
|
|
38
|
+
}
|
|
39
|
+
function relationToRoleHint(type) {
|
|
40
|
+
switch (type) {
|
|
41
|
+
case "support":
|
|
42
|
+
return "support";
|
|
43
|
+
case "joint-support":
|
|
44
|
+
return "joint-support";
|
|
45
|
+
case "derivation-support":
|
|
46
|
+
return "derivation";
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Pure helper exposed for direct testing.
|
|
51
|
+
*/
|
|
52
|
+
export function compileFormulas(input) {
|
|
53
|
+
const claimToSymbol = buildClaimToSymbol(input.variables);
|
|
54
|
+
const noopEmit = () => {
|
|
55
|
+
// intentionally empty — tests can supply addFailure to capture emits
|
|
56
|
+
};
|
|
57
|
+
const emit = input.addFailure ?? noopEmit;
|
|
58
|
+
const premises = [];
|
|
59
|
+
// Compile each relation into a premise.
|
|
60
|
+
for (const relation of input.relations) {
|
|
61
|
+
if (relation.sources.length === 0) {
|
|
62
|
+
emit({
|
|
63
|
+
code: FORMULA_COMPILATION_FAILURE_CODES.emptySources,
|
|
64
|
+
message: `Relation "${relation.relationId}" has no sources; cannot compile.`,
|
|
65
|
+
severity: "warning",
|
|
66
|
+
context: { relationId: relation.relationId },
|
|
67
|
+
});
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
const targetSymbol = claimToSymbol.get(relation.target);
|
|
71
|
+
if (!targetSymbol) {
|
|
72
|
+
emit({
|
|
73
|
+
code: FORMULA_COMPILATION_FAILURE_CODES.unresolvedTarget,
|
|
74
|
+
message: `Relation "${relation.relationId}" target claim "${relation.target}" has no variable assignment; dropping.`,
|
|
75
|
+
severity: "error",
|
|
76
|
+
context: {
|
|
77
|
+
relationId: relation.relationId,
|
|
78
|
+
targetClaimMiniId: relation.target,
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
const sourceSymbols = [];
|
|
84
|
+
let sourcesOk = true;
|
|
85
|
+
for (const src of relation.sources) {
|
|
86
|
+
const sym = claimToSymbol.get(src);
|
|
87
|
+
if (!sym) {
|
|
88
|
+
emit({
|
|
89
|
+
code: FORMULA_COMPILATION_FAILURE_CODES.unresolvedSource,
|
|
90
|
+
message: `Relation "${relation.relationId}" source claim "${src}" has no variable assignment; dropping.`,
|
|
91
|
+
severity: "error",
|
|
92
|
+
context: {
|
|
93
|
+
relationId: relation.relationId,
|
|
94
|
+
sourceClaimMiniId: src,
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
sourcesOk = false;
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
sourceSymbols.push(sym);
|
|
101
|
+
}
|
|
102
|
+
if (!sourcesOk)
|
|
103
|
+
continue;
|
|
104
|
+
let formula;
|
|
105
|
+
if (relation.type === "joint-support" && sourceSymbols.length > 1) {
|
|
106
|
+
formula = `(${sourceSymbols.join(" and ")}) implies ${targetSymbol}`;
|
|
107
|
+
}
|
|
108
|
+
else if (sourceSymbols.length === 1) {
|
|
109
|
+
formula = `${sourceSymbols[0]} implies ${targetSymbol}`;
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
// joint-support with exactly one source — degenerate; still
|
|
113
|
+
// compile as a plain support implication (the parens would
|
|
114
|
+
// be redundant). joint-support with zero sources is caught
|
|
115
|
+
// by the emptySources guard above.
|
|
116
|
+
formula = `${sourceSymbols.join(" and ")} implies ${targetSymbol}`;
|
|
117
|
+
}
|
|
118
|
+
premises.push({
|
|
119
|
+
premiseMiniId: input.generateId(),
|
|
120
|
+
formula,
|
|
121
|
+
roleHint: relationToRoleHint(relation.type),
|
|
122
|
+
sourceRelationId: relation.relationId,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
// Mint the conclusion premise iff conclusion-selection chose a
|
|
126
|
+
// claim AND the claim resolves to a known variable symbol.
|
|
127
|
+
let conclusionPremiseMiniId = null;
|
|
128
|
+
const conclusionClaimMiniId = input.conclusion?.conclusionMiniId ?? null;
|
|
129
|
+
if (conclusionClaimMiniId !== null) {
|
|
130
|
+
const conclusionSymbol = claimToSymbol.get(conclusionClaimMiniId);
|
|
131
|
+
if (!conclusionSymbol) {
|
|
132
|
+
emit({
|
|
133
|
+
code: FORMULA_COMPILATION_FAILURE_CODES.unresolvedConclusion,
|
|
134
|
+
message: `Conclusion claim "${conclusionClaimMiniId}" has no variable assignment; cannot mint conclusion premise.`,
|
|
135
|
+
severity: "error",
|
|
136
|
+
context: { conclusionClaimMiniId },
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
const id = input.generateId();
|
|
141
|
+
premises.push({
|
|
142
|
+
premiseMiniId: id,
|
|
143
|
+
formula: conclusionSymbol,
|
|
144
|
+
roleHint: "conclusion",
|
|
145
|
+
sourceRelationId: null,
|
|
146
|
+
});
|
|
147
|
+
conclusionPremiseMiniId = id;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return { premises, conclusionPremiseMiniId };
|
|
151
|
+
}
|
|
152
|
+
export const formulaCompilationStage = deterministicStage({
|
|
153
|
+
id: STAGE_IDS.formulaCompilation,
|
|
154
|
+
dependsOn: [
|
|
155
|
+
STAGE_IDS.relationExtraction,
|
|
156
|
+
STAGE_IDS.conclusionSelection,
|
|
157
|
+
STAGE_IDS.variableAssignment,
|
|
158
|
+
STAGE_IDS.claimTypeClassification,
|
|
159
|
+
],
|
|
160
|
+
outputSchema: FormulaCompilationOutputSchema,
|
|
161
|
+
fn: (ctx) => {
|
|
162
|
+
const relationEnvelope = ctx.get(STAGE_IDS.relationExtraction);
|
|
163
|
+
const relations = relationEnvelope?.relations ?? [];
|
|
164
|
+
const conclusion = ctx.get(STAGE_IDS.conclusionSelection);
|
|
165
|
+
const variables = ctx.get(STAGE_IDS.variableAssignment) ?? [];
|
|
166
|
+
return compileFormulas({
|
|
167
|
+
relations,
|
|
168
|
+
conclusion,
|
|
169
|
+
variables,
|
|
170
|
+
generateId: ctx.generateId,
|
|
171
|
+
addFailure: ctx.addFailure,
|
|
172
|
+
});
|
|
173
|
+
},
|
|
174
|
+
});
|
|
175
|
+
//# sourceMappingURL=formula-compilation.js.map
|