@proposit/proposit-core 1.2.0 → 1.3.1

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.
Files changed (100) hide show
  1. package/README.md +9 -0
  2. package/dist/extensions/argument-ingestion/index.d.ts +8 -2
  3. package/dist/extensions/argument-ingestion/index.d.ts.map +1 -1
  4. package/dist/extensions/argument-ingestion/index.js +11 -5
  5. package/dist/extensions/argument-ingestion/index.js.map +1 -1
  6. package/dist/extensions/argument-ingestion/shared/finalize-response-v2.d.ts +17 -0
  7. package/dist/extensions/argument-ingestion/shared/finalize-response-v2.d.ts.map +1 -0
  8. package/dist/extensions/argument-ingestion/shared/finalize-response-v2.js +185 -0
  9. package/dist/extensions/argument-ingestion/shared/finalize-response-v2.js.map +1 -0
  10. package/dist/extensions/argument-ingestion/shared/resolve-llm-stage-options.d.ts +19 -0
  11. package/dist/extensions/argument-ingestion/shared/resolve-llm-stage-options.d.ts.map +1 -0
  12. package/dist/extensions/argument-ingestion/shared/resolve-llm-stage-options.js +44 -0
  13. package/dist/extensions/argument-ingestion/shared/resolve-llm-stage-options.js.map +1 -0
  14. package/dist/extensions/argument-ingestion/shared/types.d.ts +39 -0
  15. package/dist/extensions/argument-ingestion/shared/types.d.ts.map +1 -1
  16. package/dist/extensions/argument-ingestion/stages/axiom-indicator-detection.d.ts +12 -0
  17. package/dist/extensions/argument-ingestion/stages/axiom-indicator-detection.d.ts.map +1 -0
  18. package/dist/extensions/argument-ingestion/stages/axiom-indicator-detection.js +51 -0
  19. package/dist/extensions/argument-ingestion/stages/axiom-indicator-detection.js.map +1 -0
  20. package/dist/extensions/argument-ingestion/stages/citation-source-detection.d.ts +12 -0
  21. package/dist/extensions/argument-ingestion/stages/citation-source-detection.d.ts.map +1 -0
  22. package/dist/extensions/argument-ingestion/stages/citation-source-detection.js +51 -0
  23. package/dist/extensions/argument-ingestion/stages/citation-source-detection.js.map +1 -0
  24. package/dist/extensions/argument-ingestion/stages/claim-canonicalization.d.ts +21 -0
  25. package/dist/extensions/argument-ingestion/stages/claim-canonicalization.d.ts.map +1 -0
  26. package/dist/extensions/argument-ingestion/stages/claim-canonicalization.js +157 -0
  27. package/dist/extensions/argument-ingestion/stages/claim-canonicalization.js.map +1 -0
  28. package/dist/extensions/argument-ingestion/stages/claim-mention-extraction.d.ts +12 -0
  29. package/dist/extensions/argument-ingestion/stages/claim-mention-extraction.d.ts.map +1 -0
  30. package/dist/extensions/argument-ingestion/stages/claim-mention-extraction.js +47 -0
  31. package/dist/extensions/argument-ingestion/stages/claim-mention-extraction.js.map +1 -0
  32. package/dist/extensions/argument-ingestion/stages/claim-reference-validation.d.ts +37 -0
  33. package/dist/extensions/argument-ingestion/stages/claim-reference-validation.d.ts.map +1 -0
  34. package/dist/extensions/argument-ingestion/stages/claim-reference-validation.js +108 -0
  35. package/dist/extensions/argument-ingestion/stages/claim-reference-validation.js.map +1 -0
  36. package/dist/extensions/argument-ingestion/stages/claim-type-classification.d.ts +12 -0
  37. package/dist/extensions/argument-ingestion/stages/claim-type-classification.d.ts.map +1 -0
  38. package/dist/extensions/argument-ingestion/stages/claim-type-classification.js +76 -0
  39. package/dist/extensions/argument-ingestion/stages/claim-type-classification.js.map +1 -0
  40. package/dist/extensions/argument-ingestion/stages/conclusion-selection.d.ts +27 -0
  41. package/dist/extensions/argument-ingestion/stages/conclusion-selection.d.ts.map +1 -0
  42. package/dist/extensions/argument-ingestion/stages/conclusion-selection.js +104 -0
  43. package/dist/extensions/argument-ingestion/stages/conclusion-selection.js.map +1 -0
  44. package/dist/extensions/argument-ingestion/stages/formula-compilation.d.ts +27 -0
  45. package/dist/extensions/argument-ingestion/stages/formula-compilation.d.ts.map +1 -0
  46. package/dist/extensions/argument-ingestion/stages/formula-compilation.js +175 -0
  47. package/dist/extensions/argument-ingestion/stages/formula-compilation.js.map +1 -0
  48. package/dist/extensions/argument-ingestion/stages/formula-validation.d.ts +19 -0
  49. package/dist/extensions/argument-ingestion/stages/formula-validation.d.ts.map +1 -0
  50. package/dist/extensions/argument-ingestion/stages/formula-validation.js +101 -0
  51. package/dist/extensions/argument-ingestion/stages/formula-validation.js.map +1 -0
  52. package/dist/extensions/argument-ingestion/stages/index.d.ts +15 -0
  53. package/dist/extensions/argument-ingestion/stages/index.d.ts.map +1 -0
  54. package/dist/extensions/argument-ingestion/stages/index.js +16 -0
  55. package/dist/extensions/argument-ingestion/stages/index.js.map +1 -0
  56. package/dist/extensions/argument-ingestion/stages/relation-extraction.d.ts +13 -0
  57. package/dist/extensions/argument-ingestion/stages/relation-extraction.d.ts.map +1 -0
  58. package/dist/extensions/argument-ingestion/stages/relation-extraction.js +87 -0
  59. package/dist/extensions/argument-ingestion/stages/relation-extraction.js.map +1 -0
  60. package/dist/extensions/argument-ingestion/stages/schemas.d.ts +161 -0
  61. package/dist/extensions/argument-ingestion/stages/schemas.d.ts.map +1 -0
  62. package/dist/extensions/argument-ingestion/stages/schemas.js +218 -0
  63. package/dist/extensions/argument-ingestion/stages/schemas.js.map +1 -0
  64. package/dist/extensions/argument-ingestion/stages/segmentation.d.ts +26 -0
  65. package/dist/extensions/argument-ingestion/stages/segmentation.d.ts.map +1 -0
  66. package/dist/extensions/argument-ingestion/stages/segmentation.js +81 -0
  67. package/dist/extensions/argument-ingestion/stages/segmentation.js.map +1 -0
  68. package/dist/extensions/argument-ingestion/stages/variable-assignment.d.ts +15 -0
  69. package/dist/extensions/argument-ingestion/stages/variable-assignment.d.ts.map +1 -0
  70. package/dist/extensions/argument-ingestion/stages/variable-assignment.js +84 -0
  71. package/dist/extensions/argument-ingestion/stages/variable-assignment.js.map +1 -0
  72. package/dist/extensions/argument-ingestion/v1-single-shot.d.ts +9 -1
  73. package/dist/extensions/argument-ingestion/v1-single-shot.d.ts.map +1 -1
  74. package/dist/extensions/argument-ingestion/v1-single-shot.js +13 -6
  75. package/dist/extensions/argument-ingestion/v1-single-shot.js.map +1 -1
  76. package/dist/extensions/argument-ingestion/v2-multi-stage.d.ts +38 -0
  77. package/dist/extensions/argument-ingestion/v2-multi-stage.d.ts.map +1 -0
  78. package/dist/extensions/argument-ingestion/v2-multi-stage.js +100 -0
  79. package/dist/extensions/argument-ingestion/v2-multi-stage.js.map +1 -0
  80. package/dist/extensions/openai/provider.d.ts.map +1 -1
  81. package/dist/extensions/openai/provider.js +136 -1
  82. package/dist/extensions/openai/provider.js.map +1 -1
  83. package/dist/extensions/openai/types.d.ts +19 -0
  84. package/dist/extensions/openai/types.d.ts.map +1 -1
  85. package/dist/lib/index.d.ts +2 -2
  86. package/dist/lib/index.d.ts.map +1 -1
  87. package/dist/lib/index.js +1 -1
  88. package/dist/lib/index.js.map +1 -1
  89. package/dist/lib/pipelines/debug-log.d.ts +96 -0
  90. package/dist/lib/pipelines/debug-log.d.ts.map +1 -0
  91. package/dist/lib/pipelines/debug-log.js +144 -0
  92. package/dist/lib/pipelines/debug-log.js.map +1 -0
  93. package/dist/lib/pipelines/execute.d.ts.map +1 -1
  94. package/dist/lib/pipelines/execute.js +84 -54
  95. package/dist/lib/pipelines/execute.js.map +1 -1
  96. package/dist/lib/pipelines/index.d.ts +1 -0
  97. package/dist/lib/pipelines/index.d.ts.map +1 -1
  98. package/dist/lib/pipelines/index.js +1 -0
  99. package/dist/lib/pipelines/index.js.map +1 -1
  100. package/package.json +2 -3
@@ -0,0 +1,157 @@
1
+ // `claim-canonicalization` — merges the raw mentions into a single
2
+ // canonical claim set. Each canonical claim carries:
3
+ // - a miniId (c1, c2, ...) allocated by the stage
4
+ // - the mentionIds it absorbed
5
+ // - a `suggestedSymbol` — the canonicalizer's snake_case-shaped
6
+ // proposal (validated downstream by variable-assignment)
7
+ // - the extension's per-claim fields (e.g. for `basics`: a
8
+ // discriminated union over `type` with title/body/url/axiom)
9
+ //
10
+ // `mentionToClaim` maps every mention id back to its assigned
11
+ // canonical claim's miniId — useful for downstream stages (and
12
+ // finalize) that want to trace evidence back to the text.
13
+ //
14
+ // Per spec §6.4 this is a strong-reasoning stage: `gpt-5.5` with
15
+ // `reasoningEffort: 'medium'`.
16
+ import Type, {} from "typebox";
17
+ import { MentionToClaimEntrySchema, STAGE_IDS, } from "./schemas.js";
18
+ import { llmStage } from "../../../lib/pipelines/stage-helpers.js";
19
+ import { optional } from "../../../lib/pipelines/types.js";
20
+ export const CLAIM_CANONICALIZATION_MODEL = "gpt-5.5";
21
+ export const CLAIM_CANONICALIZATION_REASONING = "medium";
22
+ export const CLAIM_CANONICALIZATION_SYSTEM_PROMPT = `You merge raw claim mentions into a single canonical set of claims for an argument-ingestion pipeline.
23
+
24
+ You are given:
25
+ - the raw input text (for full context)
26
+ - the segmented breakdown of the text
27
+ - the list of every claim mention extracted from those segments
28
+ - optionally, the detected citation sources + axiom indicators
29
+
30
+ Your output has two parts:
31
+
32
+ 1. \`canonicalClaims\` — an array of canonical claims, one entry per distinct proposition the author makes. Two mentions that assert the same proposition (even when phrased differently across the text) merge into a single canonical claim. Each canonical claim carries:
33
+ - \`miniId\` — assign in canonicalization order: c1, c2, c3, ...
34
+ - \`mentionIds\` — list of the mention ids that resolved to this claim
35
+ - \`type\` — one of "normal", "citation", or "axiomatic" (see below)
36
+ - \`suggestedSymbol\` — a short PascalCase-or-snake_case identifier summarizing the claim (e.g. "Rain_Wets_Ground", "NASA_Temp_Rise", "Socrates_Mortal"). Use letters, digits, and underscores only; start with a letter or underscore; keep under 32 characters; aim for under 20. AVOID single letters and generic names like "Claim1".
37
+ - the extension fields described in your output schema (title, body, url, axiom — whichever apply to the claim's \`type\`)
38
+
39
+ 2. \`mentionToClaim\` — an array of \`{ "mentionId": "...", "claimMiniId": "..." }\` entries, one per input mention. Every input mentionId must appear in exactly one entry; the mapping is total. (We surface this as a list rather than a map because the response schema does not allow arbitrary string keys.)
40
+
41
+ ## Claim types
42
+
43
+ - \`"normal"\` — a primary proposition the argument argues for or from.
44
+ - \`"citation"\` — a claim whose content is "the cited source asserts X". Use this type when one of the citation sources covers the same span(s) as the mention. Populate \`url\` (the URL if present) and \`title\` (a short human-readable label).
45
+ - \`"axiomatic"\` — a claim invoked as self-evident truth. Use this type when an axiom indicator (e.g. "by definition") covers or precedes the mention. Populate \`axiom\` with the gist of the self-evident proposition.
46
+
47
+ When a mention is the antecedent of "according to X, P", split it into two claims: a citation-typed claim for the source itself + a normal-typed claim for the proposition. The two are connected via a relation in a later stage, not here.
48
+
49
+ ## Style
50
+
51
+ - Claim titles + bodies are written in third-person, present-tense, active voice.
52
+ - Titles are short (≤ 50 characters); bodies fill in the detail.
53
+ - For citation claims, the title summarizes what the source asserts (e.g. "NASA reports temperature rise"); the URL goes in \`url\`.
54
+ - For axiomatic claims, the \`axiom\` field captures the self-evident proposition (e.g. "A bachelor is an unmarried man by definition.").
55
+
56
+ Output ONLY the schema-shaped object. No prose.`;
57
+ function buildResponseSchema(extension) {
58
+ return Type.Object({
59
+ canonicalClaims: Type.Array(buildClaimRecordSchema(extension.claimSchema)),
60
+ // List-shape (not Record/map) for OpenAI strict-mode
61
+ // compatibility — see `MentionToClaimEntrySchema` docstring
62
+ // in `./schemas.ts` for the OpenAI 400 chain that motivated
63
+ // the shape change.
64
+ mentionToClaim: Type.Array(MentionToClaimEntrySchema),
65
+ }, { additionalProperties: false });
66
+ }
67
+ function buildClaimRecordSchema(claimSchema) {
68
+ // claimSchema is the extension's claim shape — often a
69
+ // discriminated union over `type`. We need to inject the
70
+ // canonicalizer-owned fields (miniId / mentionIds / suggestedSymbol)
71
+ // into each branch.
72
+ const canonicalFields = {
73
+ miniId: Type.String({
74
+ description: "Sequential canonicalization id (c1, c2, ...).",
75
+ }),
76
+ mentionIds: Type.Array(Type.String(), {
77
+ description: "Mention ids merged into this canonical claim.",
78
+ }),
79
+ suggestedSymbol: Type.String({
80
+ description: "Snake_case / PascalCase identifier proposal for the claim's logical variable. ≤ 32 chars; letters / digits / underscores; starts with letter or underscore.",
81
+ }),
82
+ };
83
+ const ext = claimSchema;
84
+ const anyOf = ext.anyOf;
85
+ if (Array.isArray(anyOf)) {
86
+ const branches = anyOf.map((branch) => {
87
+ const branchProps = branch
88
+ .properties;
89
+ if (!branchProps) {
90
+ throw new Error("claim-canonicalization: union extension branches must be object schemas.");
91
+ }
92
+ return Type.Object({ ...canonicalFields, ...branchProps }, { additionalProperties: false });
93
+ });
94
+ return Type.Union(branches);
95
+ }
96
+ const objProps = ext.properties;
97
+ if (!objProps) {
98
+ throw new Error("claim-canonicalization: extension claimSchema must be a Type.Object or a Type.Union of Type.Objects.");
99
+ }
100
+ return Type.Object({ ...canonicalFields, ...objProps }, { additionalProperties: false });
101
+ }
102
+ function buildPrompt(ctx) {
103
+ const input = ctx.input;
104
+ const mentionEnvelope = ctx.get(STAGE_IDS.claimMentionExtraction);
105
+ const mentions = mentionEnvelope?.mentions ?? [];
106
+ const citationEnvelope = ctx.get(STAGE_IDS.citationSourceDetection);
107
+ const citations = citationEnvelope?.sources ?? [];
108
+ const axiomEnvelope = ctx.get(STAGE_IDS.axiomIndicatorDetection);
109
+ const axioms = axiomEnvelope?.axioms ?? [];
110
+ const mentionLines = mentions
111
+ .map((m) => ` [${m.mentionId} @ ${m.segmentId}] ${JSON.stringify(m.text)}`)
112
+ .join("\n");
113
+ const citationLines = citations.length > 0
114
+ ? citations
115
+ .map((c) => ` [${c.sourceId} @ ${c.segmentIds.join(",")}] ${JSON.stringify(c.sourceString)}${c.url ? ` (url: ${c.url})` : ""}`)
116
+ .join("\n")
117
+ : " (none)";
118
+ const axiomLines = axioms.length > 0
119
+ ? axioms
120
+ .map((a) => ` [${a.axiomId} @ ${a.segmentIds.join(",")}] ${JSON.stringify(a.indicator)}`)
121
+ .join("\n")
122
+ : " (none)";
123
+ const markedSystem = `<!-- stage-id: ${STAGE_IDS.claimCanonicalization} -->\n${CLAIM_CANONICALIZATION_SYSTEM_PROMPT}`;
124
+ const user = `Input text:\n\n${input.text}\n\nClaim mentions:\n${mentionLines}\n\nDetected citation sources:\n${citationLines}\n\nDetected axiom indicators:\n${axiomLines}\n\nProduce the canonicalClaims + mentionToClaim object.`;
125
+ return { system: markedSystem, user };
126
+ }
127
+ /** Internal default knobs for the claim-canonicalization stage. */
128
+ export const CLAIM_CANONICALIZATION_STAGE_DEFAULTS = {
129
+ reasoningEffort: CLAIM_CANONICALIZATION_REASONING,
130
+ };
131
+ /**
132
+ * Builds the `claim-canonicalization` stage for the supplied
133
+ * extension. The stage's `outputSchema` carries the extension's
134
+ * per-claim fields, so the LLM's structured-output schema matches the
135
+ * extension's claim shape (e.g. for `basics`: a discriminated union
136
+ * over `type`).
137
+ *
138
+ * `options` overrides the stage's internal defaults
139
+ * (`CLAIM_CANONICALIZATION_STAGE_DEFAULTS`). Threaded through by
140
+ * `createIngestionV2Pipeline` per its `TIngestionLlmOptions` surface.
141
+ */
142
+ export function createClaimCanonicalizationStage(extension, options) {
143
+ return llmStage({
144
+ id: STAGE_IDS.claimCanonicalization,
145
+ dependsOn: [
146
+ STAGE_IDS.claimMentionExtraction,
147
+ optional(STAGE_IDS.citationSourceDetection),
148
+ optional(STAGE_IDS.axiomIndicatorDetection),
149
+ ],
150
+ outputSchema: buildResponseSchema(extension),
151
+ model: CLAIM_CANONICALIZATION_MODEL,
152
+ maxOutputTokens: options?.maxOutputTokens,
153
+ reasoningEffort: options?.reasoningEffort ?? CLAIM_CANONICALIZATION_REASONING,
154
+ buildPrompt,
155
+ });
156
+ }
157
+ //# sourceMappingURL=claim-canonicalization.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claim-canonicalization.js","sourceRoot":"","sources":["../../../../src/extensions/argument-ingestion/stages/claim-canonicalization.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,qDAAqD;AACrD,oDAAoD;AACpD,iCAAiC;AACjC,kEAAkE;AAClE,6DAA6D;AAC7D,6DAA6D;AAC7D,iEAAiE;AACjE,EAAE;AACF,8DAA8D;AAC9D,+DAA+D;AAC/D,0DAA0D;AAC1D,EAAE;AACF,iEAAiE;AACjE,+BAA+B;AAE/B,OAAO,IAAI,EAAE,EAAgB,MAAM,SAAS,C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,EAAE,CAAA;AACzC,CAAC;AAED,mEAAmE;AACnE,MAAM,CAAC,MAAM,qCAAqC,GAA6B;IAC3E,eAAe,EAAE,gCAAgC;CACpD,CAAA;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,gCAAgC,CAC5C,SAA8B,EAC9B,OAAkC;IAElC,OAAO,QAAQ,CAA+B;QAC1C,EAAE,EAAE,SAAS,CAAC,qBAAqB;QACnC,SAAS,EAAE;YACP,SAAS,CAAC,sBAAsB;YAChC,QAAQ,CAAC,SAAS,CAAC,uBAAuB,CAAC;YAC3C,QAAQ,CAAC,SAAS,CAAC,uBAAuB,CAAC;SAC9C;QACD,YAAY,EAAE,mBAAmB,CAAC,SAAS,CAAC;QAC5C,KAAK,EAAE,4BAA4B;QACnC,eAAe,EAAE,OAAO,EAAE,eAAe;QACzC,eAAe,EACX,OAAO,EAAE,eAAe,IAAI,gCAAgC;QAChE,WAAW;KACd,CAAC,CAAA;AACN,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { type TClaimMentionExtractionOutput } from "./schemas.js";
2
+ import type { TStage } from "../../../lib/pipelines/types.js";
3
+ import type { TLlmStageOptionsOverride } from "../shared/types.js";
4
+ export declare const CLAIM_MENTION_EXTRACTION_MODEL = "gpt-5.4";
5
+ export declare 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 \u2014 a sentence-or-clause-sized chunk that a reader would read as a single assertion.\n\nReturn an object with a single key `mentions` whose value is the array of extracted mentions. For each mention emit:\n- a fresh \"mentionId\" (m1, m2, ...; unique across all segments)\n- the \"segmentId\" the mention belongs to\n- the verbatim \"text\" of the mention (copy from the input \u2014 do not rewrite)\n- the character \"span\" (an object with \"start\" inclusive, \"end\" exclusive) relative to the SEGMENT'S TEXT (not the original input)\n\nA single segment can produce multiple mentions when it asserts multiple things. Most segments produce one mention. Do NOT deduplicate \u2014 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.\n\nIf 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\": [] }`.";
6
+ /** Internal default knobs for the claim-mention-extraction stage. */
7
+ export declare const CLAIM_MENTION_EXTRACTION_STAGE_DEFAULTS: TLlmStageOptionsOverride;
8
+ /** Build the claim-mention-extraction stage with optional caller overrides. */
9
+ export declare function createClaimMentionExtractionStage(options?: TLlmStageOptionsOverride): TStage<TClaimMentionExtractionOutput>;
10
+ /** Backward-compatible default-options stage. */
11
+ export declare const claimMentionExtractionStage: TStage<TClaimMentionExtractionOutput>;
12
+ //# sourceMappingURL=claim-mention-extraction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claim-mention-extraction.d.ts","sourceRoot":"","sources":["../../../../src/extensions/argument-ingestion/stages/claim-mention-extraction.ts"],"names":[],"mappings":"AAOA,OAAO,EAGH,KAAK,6BAA6B,EAErC,MAAM,cAAc,CAAA;AAErB,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,iCAAiC,CAAA;AAC5E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAA;AAElE,eAAO,MAAM,8BAA8B,YAAY,CAAA;AAEvD,eAAO,MAAM,sCAAsC,svCAUoH,CAAA;AAavK,qEAAqE;AACrE,eAAO,MAAM,uCAAuC,EAAE,wBAChD,CAAA;AAEN,+EAA+E;AAC/E,wBAAgB,iCAAiC,CAC7C,OAAO,CAAC,EAAE,wBAAwB,GACnC,MAAM,CAAC,6BAA6B,CAAC,CAUvC;AAED,iDAAiD;AACjD,eAAO,MAAM,2BAA2B,EAAE,MAAM,CAAC,6BAA6B,CACvC,CAAA"}
@@ -0,0 +1,47 @@
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
+ /** Internal default knobs for the claim-mention-extraction stage. */
32
+ export const CLAIM_MENTION_EXTRACTION_STAGE_DEFAULTS = {};
33
+ /** Build the claim-mention-extraction stage with optional caller overrides. */
34
+ export function createClaimMentionExtractionStage(options) {
35
+ return llmStage({
36
+ id: STAGE_IDS.claimMentionExtraction,
37
+ dependsOn: [STAGE_IDS.segmentation],
38
+ outputSchema: ClaimMentionExtractionOutputSchema,
39
+ model: CLAIM_MENTION_EXTRACTION_MODEL,
40
+ maxOutputTokens: options?.maxOutputTokens,
41
+ reasoningEffort: options?.reasoningEffort,
42
+ buildPrompt,
43
+ });
44
+ }
45
+ /** Backward-compatible default-options stage. */
46
+ export const claimMentionExtractionStage = createClaimMentionExtractionStage();
47
+ //# 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;AAIlE,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,qEAAqE;AACrE,MAAM,CAAC,MAAM,uCAAuC,GAChD,EAAE,CAAA;AAEN,+EAA+E;AAC/E,MAAM,UAAU,iCAAiC,CAC7C,OAAkC;IAElC,OAAO,QAAQ,CAAgC;QAC3C,EAAE,EAAE,SAAS,CAAC,sBAAsB;QACpC,SAAS,EAAE,CAAC,SAAS,CAAC,YAAY,CAAC;QACnC,YAAY,EAAE,kCAAkC;QAChD,KAAK,EAAE,8BAA8B;QACrC,eAAe,EAAE,OAAO,EAAE,eAAe;QACzC,eAAe,EAAE,OAAO,EAAE,eAAe;QACzC,WAAW;KACd,CAAC,CAAA;AACN,CAAC;AAED,iDAAiD;AACjD,MAAM,CAAC,MAAM,2BAA2B,GACpC,iCAAiC,EAAE,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;AACnE,qEAAqE;AACrE,+CAA+C;AAE/C,OAAO,EACH,SAAS,EACT,2BAA2B,GAG9B,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAA;AAG5E,MAAM,CAAC,MAAM,6BAA6B,GAAG;IACzC,eAAe,EAAE,wBAAwB;IACzC,eAAe,EAAE,gCAAgC;IACjD,cAAc,EAAE,wBAAwB;IACxC,gBAAgB,EAAE,0BAA0B;CACtC,CAAA;AAgBV;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,KAAmC;IAOvE,MAAM,QAAQ,GAIR,EAAE,CAAA;IAER,wBAAwB;IACxB,MAAM,YAAY,GAAG,IAAI,GAAG,EAAkB,CAAA;IAC9C,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,eAAe,EAAE,CAAC;QACxC,YAAY,CAAC,GAAG,CACZ,KAAK,CAA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AAO,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,12 @@
1
+ import { type TClaimTypeClassificationOutput } from "./schemas.js";
2
+ import type { TStage } from "../../../lib/pipelines/types.js";
3
+ import type { TLlmStageOptionsOverride } from "../shared/types.js";
4
+ export declare const CLAIM_TYPE_CLASSIFICATION_MODEL = "gpt-5.4";
5
+ 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.";
6
+ /** Internal default knobs for the claim-type-classification stage. */
7
+ export declare const CLAIM_TYPE_CLASSIFICATION_STAGE_DEFAULTS: TLlmStageOptionsOverride;
8
+ /** Build the claim-type-classification stage with optional caller overrides. */
9
+ export declare function createClaimTypeClassificationStage(options?: TLlmStageOptionsOverride): TStage<TClaimTypeClassificationOutput>;
10
+ /** Backward-compatible default-options stage. */
11
+ export declare const claimTypeClassificationStage: TStage<TClaimTypeClassificationOutput>;
12
+ //# 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;AAC5E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAA;AAElE,eAAO,MAAM,+BAA+B,YAAY,CAAA;AAExD,eAAO,MAAM,uCAAuC,82CAesF,CAAA;AAqD1I,sEAAsE;AACtE,eAAO,MAAM,wCAAwC,EAAE,wBACjD,CAAA;AAEN,gFAAgF;AAChF,wBAAgB,kCAAkC,CAC9C,OAAO,CAAC,EAAE,wBAAwB,GACnC,MAAM,CAAC,8BAA8B,CAAC,CAcxC;AAED,iDAAiD;AACjD,eAAO,MAAM,4BAA4B,EAAE,MAAM,CAAC,8BAA8B,CACxC,CAAA"}
@@ -0,0 +1,76 @@
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
+ /** Internal default knobs for the claim-type-classification stage. */
57
+ export const CLAIM_TYPE_CLASSIFICATION_STAGE_DEFAULTS = {};
58
+ /** Build the claim-type-classification stage with optional caller overrides. */
59
+ export function createClaimTypeClassificationStage(options) {
60
+ return llmStage({
61
+ id: STAGE_IDS.claimTypeClassification,
62
+ dependsOn: [
63
+ STAGE_IDS.claimCanonicalization,
64
+ optional(STAGE_IDS.citationSourceDetection),
65
+ optional(STAGE_IDS.axiomIndicatorDetection),
66
+ ],
67
+ outputSchema: ClaimTypeClassificationOutputSchema,
68
+ model: CLAIM_TYPE_CLASSIFICATION_MODEL,
69
+ maxOutputTokens: options?.maxOutputTokens,
70
+ reasoningEffort: options?.reasoningEffort,
71
+ buildPrompt,
72
+ });
73
+ }
74
+ /** Backward-compatible default-options stage. */
75
+ export const claimTypeClassificationStage = createClaimTypeClassificationStage();
76
+ //# 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,EAA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ACN,CAAC;AAED,iDAAiD;AACjD,MAAM,CAAC,MAAM,4BAA4B,GACrC,kCAAkC,EAAE,CAAA"}
@@ -0,0 +1,27 @@
1
+ import { type TConclusionSelectionOutput } from "./schemas.js";
2
+ import type { TStage } from "../../../lib/pipelines/types.js";
3
+ import type { TLlmStageOptionsOverride } from "../shared/types.js";
4
+ export declare const CONCLUSION_SELECTION_MODEL = "gpt-5.5";
5
+ export declare const CONCLUSION_SELECTION_REASONING: "minimal" | "low" | "medium" | "high";
6
+ export declare const CONCLUSION_SELECTION_NO_CONCLUSION_FAILURE_CODE = "NO_SINGLE_CONCLUSION";
7
+ 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.";
8
+ /** Internal default knobs for the conclusion-selection stage. */
9
+ export declare const CONCLUSION_SELECTION_STAGE_DEFAULTS: TLlmStageOptionsOverride;
10
+ /**
11
+ * Build the conclusion-selection stage with optional caller
12
+ * overrides. The stage wraps an inner `llmStage` so that when the LLM
13
+ * returns `conclusionMiniId: null`, it also emits a
14
+ * `ProcessingFailure` with code `NO_SINGLE_CONCLUSION` via
15
+ * `ctx.addFailure` (spec §7.2 row 10). The stage still completes
16
+ * successfully — the null output flows through `formula-compilation`
17
+ * (which emits `conclusionPremiseMiniId: null`) into
18
+ * `finalize-response-v2` (which assembles `{ argument: null,
19
+ * failureText: "No single conclusion could be selected." }`). The
20
+ * added failure is a UI-rendering hint, not a task-outcome signal;
21
+ * severity is `warning` to match the informational-only role of
22
+ * finalize's failureText path.
23
+ */
24
+ export declare function createConclusionSelectionStage(options?: TLlmStageOptionsOverride): TStage<TConclusionSelectionOutput>;
25
+ /** Backward-compatible default-options stage. */
26
+ export declare const conclusionSelectionStage: TStage<TConclusionSelectionOutput>;
27
+ //# 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;AAC5E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAA;AAElE,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;AA8BtN,iEAAiE;AACjE,eAAO,MAAM,mCAAmC,EAAE,wBAEjD,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,8BAA8B,CAC1C,OAAO,CAAC,EAAE,wBAAwB,GACnC,MAAM,CAAC,0BAA0B,CAAC,CAkCpC;AAED,iDAAiD;AACjD,eAAO,MAAM,wBAAwB,EAAE,MAAM,CAAC,0BAA0B,CACpC,CAAA"}