@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,104 @@
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
+ /** Internal default knobs for the conclusion-selection stage. */
52
+ export const CONCLUSION_SELECTION_STAGE_DEFAULTS = {
53
+ reasoningEffort: CONCLUSION_SELECTION_REASONING,
54
+ };
55
+ /**
56
+ * Build the conclusion-selection stage with optional caller
57
+ * overrides. The stage wraps an inner `llmStage` so that when the LLM
58
+ * returns `conclusionMiniId: null`, it also emits a
59
+ * `ProcessingFailure` with code `NO_SINGLE_CONCLUSION` via
60
+ * `ctx.addFailure` (spec §7.2 row 10). The stage still completes
61
+ * successfully — the null output flows through `formula-compilation`
62
+ * (which emits `conclusionPremiseMiniId: null`) into
63
+ * `finalize-response-v2` (which assembles `{ argument: null,
64
+ * failureText: "No single conclusion could be selected." }`). The
65
+ * added failure is a UI-rendering hint, not a task-outcome signal;
66
+ * severity is `warning` to match the informational-only role of
67
+ * finalize's failureText path.
68
+ */
69
+ export function createConclusionSelectionStage(options) {
70
+ const innerStage = llmStage({
71
+ id: STAGE_IDS.conclusionSelection,
72
+ dependsOn: [
73
+ STAGE_IDS.claimTypeClassification,
74
+ STAGE_IDS.relationExtraction,
75
+ ],
76
+ outputSchema: ConclusionSelectionOutputSchema,
77
+ model: CONCLUSION_SELECTION_MODEL,
78
+ maxOutputTokens: options?.maxOutputTokens,
79
+ reasoningEffort: options?.reasoningEffort ?? CONCLUSION_SELECTION_REASONING,
80
+ buildPrompt,
81
+ });
82
+ return {
83
+ id: innerStage.id,
84
+ dependsOn: innerStage.dependsOn,
85
+ outputSchema: innerStage.outputSchema,
86
+ run: async (ctx) => {
87
+ const output = await innerStage.run(ctx);
88
+ if (output.conclusionMiniId === null) {
89
+ ctx.addFailure({
90
+ code: CONCLUSION_SELECTION_NO_CONCLUSION_FAILURE_CODE,
91
+ message: output.rationale.length > 0
92
+ ? output.rationale
93
+ : "No single conclusion could be selected.",
94
+ severity: "warning",
95
+ context: { rationale: output.rationale },
96
+ });
97
+ }
98
+ return output;
99
+ },
100
+ };
101
+ }
102
+ /** Backward-compatible default-options stage. */
103
+ export const conclusionSelectionStage = createConclusionSelectionStage();
104
+ //# 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;AAIlE,MAAM,CAAC,MAAM,0BAA0B,GAAG,SAAS,CAAA;AACnD,MAAM,CAAC,MAAM,8BAA8B,GAI5B,QAAQ,CAAA;AAEvB,MAAM,CAAC,MAAM,+CAA+C,GACxD,sBAAsB,CAAA;AAE1B,MAAM,CAAC,MAAM,kCAAkC,GAAG;;;;;;;;;;;;;;;;;sNAiBoK,CAAA;AAEtN,SAAS,WAAW,CAAC,GAAkB;IACnC,MAAM,YAAY,GAAG,GAAG,CAAC,GAAG,CACxB,SAAS,CAAC,uBAAuB,CACpC,CAAA;IACD,MAAM,eAAe,GAAG,YAAY,EAAE,eAAe,IAAI,EAAE,CAAA;IAC3D,MAAM,gBAAgB,GAAG,GAAG,CAAC,GAAG,CAC5B,SAAS,CAAC,kBAAkB,CAC/B,CAAA;IACD,MAAM,SAAS,GAAG,gBAAgB,EAAE,SAAS,IAAI,EAAE,CAAA;IAEnD,MAAM,SAAS,GAAG,eAAe;SAC5B,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,KAAK,CAAC,MAAM,UAAU,KAAK,CAAC,IA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E,EAAE;YACf,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;YACxC,IAAI,MAAM,CAAC,gBAAgB,KAAK,IAAI,EAAE,CAAC;gBACnC,GAAG,CAAC,UAAU,CAAC;oBACX,IAAI,EAAE,+CAA+C;oBACrD,OAAO,EACH,MAAM,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC;wBACvB,CAAC,CAAC,MAAM,CAAC,SAAS;wBAClB,CAAC,CAAC,yCAAyC;oBACnD,QAAQ,EAAE,SAAS;oBACnB,OAAO,EAAE,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE;iBAC3C,CAAC,CAAA;YACN,CAAC;YACD,OAAO,MAAM,CAAA;QACjB,CAAC;KACJ,CAAA;AACL,CAAC;AAED,iDAAiD;AACjD,MAAM,CAAC,MAAM,wBAAwB,GACjC,8BAA8B,EAAE,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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formula-compilation.js","sourceRoot":"","sources":["../../../../src/extensions/argument-ingestion/stages/formula-compilation.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,gEAAgE;AAChE,qEAAqE;AACrE,0DAA0D;AAC1D,EAAE;AACF,iCAAiC;AACjC,mEAAmE;AACnE,8EAA8E;AAC9E,mEAAmE;AACnE,EAAE;AACF,uCAAuC;AACvC,gEAAgE;AAChE,sEAAsE;AACtE,uDAAuD;AACvD,kEAAkE;AAClE,0DAA0D;AAC1D,sEAAsE;AACtE,4DAA4D;AAC5D,EAAE;AACF,qEAAqE;AACrE,qEAAqE;AACrE,kEAAkE;AAClE,+BAA+B;AAE/B,OAAO,EACH,SAAS,EACT,8BAA8B,GAMjC,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAA;AAG5E,MAAM,CAAC,MAAM,iCAAiC,GAAG;IAC7C,gBAAgB,EAAE,uCAAuC;IACzD,gBAAgB,EAAE,uCAAuC;IACzD,oBAAoB,EAAE,2CAA2C;IACjE,YAAY,EAAE,mCAAmC;CAC3C,CAAA;AAgBV,SAAS,kBAAkB,CACvB,SAAoC;IAEpC,MAAM,CAAC,GAAG,IAAI,GAAG,EAAkB,CAAA;IACnC,KAAK,MAAM,CAAC,IAAI,SAAS,EAAE,CAAC;QACxB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,CAAA;IAClC,CAAC;IACD,OAAO,CAAC,CAAA;AACZ,CAAC;AAED,SAAS,kBAAkB,CACvB,IAAwD;IAExD,QAAQ,IAAI,EAAE,CAAC;QACX,KAAK,SAAS;YACV,OAAO,SAAS,CAAA;QACpB,KAAK,eAAe;YAChB,OAAO,eAA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AE;QACvB,MAAM,gBAAgB,GAAG,GAAG,CAAC,GAAG,CAC5B,SAAS,CAAC,kBAAkB,CAC/B,CAAA;QACD,MAAM,SAAS,GAAG,gBAAgB,EAAE,SAAS,IAAI,EAAE,CAAA;QACnD,MAAM,UAAU,GAAG,GAAG,CAAC,GAAG,CACtB,SAAS,CAAC,mBAAmB,CAChC,CAAA;QACD,MAAM,SAAS,GACX,GAAG,CAAC,GAAG,CACH,SAAS,CAAC,kBAAkB,CAC/B,IAAI,EAAE,CAAA;QACX,OAAO,eAAe,CAAC;YACnB,SAAS;YACT,UAAU;YACV,SAAS;YACT,UAAU,EAAE,GAAG,CAAC,UAAU;YAC1B,UAAU,EAAE,GAAG,CAAC,UAAU;SAC7B,CAAC,CAAA;IACN,CAAC;CACJ,CAAC,CAAA"}
@@ -0,0 +1,19 @@
1
+ import { type TFormulaCompilationOutput, type TValidationStageOutput, type TVariableAssignmentOutput } from "./schemas.js";
2
+ import type { TStage } from "../../../lib/pipelines/types.js";
3
+ export declare const FORMULA_VALIDATION_FAILURE_CODES: {
4
+ readonly parseError: "FORMULA_PARSE_ERROR";
5
+ readonly symbolUnresolved: "FORMULA_SYMBOL_UNRESOLVED";
6
+ };
7
+ export type TValidateFormulasInput = {
8
+ compilation: TFormulaCompilationOutput | undefined;
9
+ variables: TVariableAssignmentOutput;
10
+ };
11
+ export declare function validateFormulas(input: TValidateFormulasInput): {
12
+ failures: {
13
+ code: string;
14
+ message: string;
15
+ context: Record<string, unknown>;
16
+ }[];
17
+ };
18
+ export declare const formulaValidationStage: TStage<TValidationStageOutput>;
19
+ //# sourceMappingURL=formula-validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formula-validation.d.ts","sourceRoot":"","sources":["../../../../src/extensions/argument-ingestion/stages/formula-validation.ts"],"names":[],"mappings":"AAcA,OAAO,EAGH,KAAK,yBAAyB,EAC9B,KAAK,sBAAsB,EAC3B,KAAK,yBAAyB,EACjC,MAAM,cAAc,CAAA;AAErB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAA;AAE7D,eAAO,MAAM,gCAAgC;;;CAGnC,CAAA;AAsBV,MAAM,MAAM,sBAAsB,GAAG;IACjC,WAAW,EAAE,yBAAyB,GAAG,SAAS,CAAA;IAClD,SAAS,EAAE,yBAAyB,CAAA;CACvC,CAAA;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,sBAAsB,GAAG;IAC7D,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,CA2CA;AAED,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,sBAAsB,CA4B5D,CAAA"}
@@ -0,0 +1,101 @@
1
+ // `formula-validation` — deterministic stage that re-parses every
2
+ // compiled formula via `parseFormula` and verifies each referenced atom
3
+ // resolves to a known variable symbol (from `variable-assignment`).
4
+ //
5
+ // Emits:
6
+ // - FORMULA_PARSE_ERROR — `parseFormula(formula)` threw.
7
+ // - FORMULA_SYMBOL_UNRESOLVED — a parsed atom is not among the known
8
+ // variable symbols.
9
+ //
10
+ // Doesn't gate downstream — `finalize` consumes `formula-compilation`'s
11
+ // premises directly. This stage is observational.
12
+ import { parseFormula } from "../../../lib/core/parser/formula.js";
13
+ import { STAGE_IDS, ValidationStageOutputSchema, } from "./schemas.js";
14
+ import { deterministicStage } from "../../../lib/pipelines/stage-helpers.js";
15
+ export const FORMULA_VALIDATION_FAILURE_CODES = {
16
+ parseError: "FORMULA_PARSE_ERROR",
17
+ symbolUnresolved: "FORMULA_SYMBOL_UNRESOLVED",
18
+ };
19
+ function collectAtoms(ast, out) {
20
+ switch (ast.type) {
21
+ case "variable":
22
+ out.add(ast.name);
23
+ return;
24
+ case "not":
25
+ collectAtoms(ast.operand, out);
26
+ return;
27
+ case "and":
28
+ case "or":
29
+ for (const child of ast.operands)
30
+ collectAtoms(child, out);
31
+ return;
32
+ case "implies":
33
+ case "iff":
34
+ collectAtoms(ast.left, out);
35
+ collectAtoms(ast.right, out);
36
+ return;
37
+ }
38
+ }
39
+ export function validateFormulas(input) {
40
+ const failures = [];
41
+ const knownSymbols = new Set(input.variables.map((v) => v.symbol));
42
+ if (!input.compilation)
43
+ return { failures };
44
+ for (const premise of input.compilation.premises) {
45
+ let ast;
46
+ try {
47
+ ast = parseFormula(premise.formula);
48
+ }
49
+ catch (err) {
50
+ failures.push({
51
+ code: FORMULA_VALIDATION_FAILURE_CODES.parseError,
52
+ message: `parseFormula failed on premise "${premise.premiseMiniId}": ${err instanceof Error ? err.message : String(err)}`,
53
+ context: {
54
+ premiseMiniId: premise.premiseMiniId,
55
+ formula: premise.formula,
56
+ },
57
+ });
58
+ continue;
59
+ }
60
+ const atoms = new Set();
61
+ collectAtoms(ast, atoms);
62
+ for (const atom of atoms) {
63
+ if (!knownSymbols.has(atom)) {
64
+ failures.push({
65
+ code: FORMULA_VALIDATION_FAILURE_CODES.symbolUnresolved,
66
+ message: `Premise "${premise.premiseMiniId}" references symbol "${atom}" which is not in variable-assignment.`,
67
+ context: {
68
+ premiseMiniId: premise.premiseMiniId,
69
+ formula: premise.formula,
70
+ unresolvedSymbol: atom,
71
+ },
72
+ });
73
+ }
74
+ }
75
+ }
76
+ return { failures };
77
+ }
78
+ export const formulaValidationStage = deterministicStage({
79
+ id: STAGE_IDS.formulaValidation,
80
+ dependsOn: [STAGE_IDS.formulaCompilation, STAGE_IDS.variableAssignment],
81
+ outputSchema: ValidationStageOutputSchema,
82
+ fn: (ctx) => {
83
+ const compilation = ctx.get(STAGE_IDS.formulaCompilation);
84
+ const variables = ctx.get(STAGE_IDS.variableAssignment) ?? [];
85
+ const { failures } = validateFormulas({ compilation, variables });
86
+ for (const f of failures) {
87
+ ctx.addFailure({
88
+ code: f.code,
89
+ message: f.message,
90
+ severity: "warning",
91
+ context: f.context,
92
+ });
93
+ }
94
+ return failures.map((f) => ({
95
+ code: f.code,
96
+ message: f.message,
97
+ context: f.context,
98
+ }));
99
+ },
100
+ });
101
+ //# sourceMappingURL=formula-validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formula-validation.js","sourceRoot":"","sources":["../../../../src/extensions/argument-ingestion/stages/formula-validation.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,wEAAwE;AACxE,oEAAoE;AACpE,EAAE;AACF,SAAS;AACT,2DAA2D;AAC3D,uEAAuE;AACvE,wBAAwB;AACxB,EAAE;AACF,wEAAwE;AACxE,kDAAkD;AAElD,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAA;AAElE,OAAO,EACH,SAAS,EACT,2BAA2B,GAI9B,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAA;AAG5E,MAAM,CAAC,MAAM,gCAAgC,GAAG;IAC5C,UAAU,EAAE,qBAAqB;IACjC,gBAAgB,EAAE,2BAA2B;CACvC,CAAA;AAEV,SAAS,YAAY,CAAC,GAAgB,EAAE,GAAgB;IACpD,QAAQ,GAAG,CAAC,IAAI,EAAE,CAAC;QACf,KAAK,UAAU;YACX,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;YACjB,OAAM;QACV,KAAK,KAAK;YACN,YAAY,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;YAC9B,OAAM;QACV,KAAK,KAAK,CAAC;QACX,KAAK,IAAI;YACL,KAAK,MAAM,KAAK,IAAI,GAAG,CAAC,QAAQ;gBAAE,YAAY,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;YAC1D,OAAM;QACV,KAAK,SAAS,CAAC;QACf,KAAK,KAAK;YACN,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;YAC3B,YAAY,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;YAC5B,OAAM;IACd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@ -0,0 +1,15 @@
1
+ export { STAGE_IDS } from "./schemas.js";
2
+ export * from "./schemas.js";
3
+ export { segmentationStage, createSegmentationStage, SEGMENTATION_MAX_OUTPUT_TOKENS, SEGMENTATION_STAGE_DEFAULTS, } from "./segmentation.js";
4
+ export { claimMentionExtractionStage, createClaimMentionExtractionStage, CLAIM_MENTION_EXTRACTION_STAGE_DEFAULTS, } from "./claim-mention-extraction.js";
5
+ export { citationSourceDetectionStage, createCitationSourceDetectionStage, CITATION_SOURCE_DETECTION_STAGE_DEFAULTS, } from "./citation-source-detection.js";
6
+ export { axiomIndicatorDetectionStage, createAxiomIndicatorDetectionStage, AXIOM_INDICATOR_DETECTION_STAGE_DEFAULTS, } from "./axiom-indicator-detection.js";
7
+ export { createClaimCanonicalizationStage, CLAIM_CANONICALIZATION_STAGE_DEFAULTS, } from "./claim-canonicalization.js";
8
+ export { claimTypeClassificationStage, createClaimTypeClassificationStage, CLAIM_TYPE_CLASSIFICATION_STAGE_DEFAULTS, } from "./claim-type-classification.js";
9
+ export { claimReferenceValidationStage, validateClaimReferences, CLAIM_REFERENCE_FAILURE_CODES, } from "./claim-reference-validation.js";
10
+ export { variableAssignmentStage, assignVariables, isValidVariableSymbol, } from "./variable-assignment.js";
11
+ export { relationExtractionStage, createRelationExtractionStage, RELATION_EXTRACTION_STAGE_DEFAULTS, } from "./relation-extraction.js";
12
+ export { conclusionSelectionStage, createConclusionSelectionStage, CONCLUSION_SELECTION_STAGE_DEFAULTS, } from "./conclusion-selection.js";
13
+ export { formulaCompilationStage, compileFormulas, FORMULA_COMPILATION_FAILURE_CODES, } from "./formula-compilation.js";
14
+ export { formulaValidationStage, validateFormulas, FORMULA_VALIDATION_FAILURE_CODES, } from "./formula-validation.js";
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/extensions/argument-ingestion/stages/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,cAAc,cAAc,CAAA;AAE5B,OAAO,EACH,iBAAiB,EACjB,uBAAuB,EACvB,8BAA8B,EAC9B,2BAA2B,GAC9B,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EACH,2BAA2B,EAC3B,iCAAiC,EACjC,uCAAuC,GAC1C,MAAM,+BAA+B,CAAA;AACtC,OAAO,EACH,4BAA4B,EAC5B,kCAAkC,EAClC,wCAAwC,GAC3C,MAAM,gCAAgC,CAAA;AACvC,OAAO,EACH,4BAA4B,EAC5B,kCAAkC,EAClC,wCAAwC,GAC3C,MAAM,gCAAgC,CAAA;AACvC,OAAO,EACH,gCAAgC,EAChC,qCAAqC,GACxC,MAAM,6BAA6B,CAAA;AACpC,OAAO,EACH,4BAA4B,EAC5B,kCAAkC,EAClC,wCAAwC,GAC3C,MAAM,gCAAgC,CAAA;AACvC,OAAO,EACH,6BAA6B,EAC7B,uBAAuB,EACvB,6BAA6B,GAChC,MAAM,iCAAiC,CAAA;AACxC,OAAO,EACH,uBAAuB,EACvB,eAAe,EACf,qBAAqB,GACxB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EACH,uBAAuB,EACvB,6BAA6B,EAC7B,kCAAkC,GACrC,MAAM,0BAA0B,CAAA;AACjC,OAAO,EACH,wBAAwB,EACxB,8BAA8B,EAC9B,mCAAmC,GACtC,MAAM,2BAA2B,CAAA;AAClC,OAAO,EACH,uBAAuB,EACvB,eAAe,EACf,iCAAiC,GACpC,MAAM,0BAA0B,CAAA;AACjC,OAAO,EACH,sBAAsB,EACtB,gBAAgB,EAChB,gCAAgC,GACnC,MAAM,yBAAyB,CAAA"}
@@ -0,0 +1,16 @@
1
+ // Barrel for the 12 v2-multi-stage ingestion stages.
2
+ export { STAGE_IDS } from "./schemas.js";
3
+ export * from "./schemas.js";
4
+ export { segmentationStage, createSegmentationStage, SEGMENTATION_MAX_OUTPUT_TOKENS, SEGMENTATION_STAGE_DEFAULTS, } from "./segmentation.js";
5
+ export { claimMentionExtractionStage, createClaimMentionExtractionStage, CLAIM_MENTION_EXTRACTION_STAGE_DEFAULTS, } from "./claim-mention-extraction.js";
6
+ export { citationSourceDetectionStage, createCitationSourceDetectionStage, CITATION_SOURCE_DETECTION_STAGE_DEFAULTS, } from "./citation-source-detection.js";
7
+ export { axiomIndicatorDetectionStage, createAxiomIndicatorDetectionStage, AXIOM_INDICATOR_DETECTION_STAGE_DEFAULTS, } from "./axiom-indicator-detection.js";
8
+ export { createClaimCanonicalizationStage, CLAIM_CANONICALIZATION_STAGE_DEFAULTS, } from "./claim-canonicalization.js";
9
+ export { claimTypeClassificationStage, createClaimTypeClassificationStage, CLAIM_TYPE_CLASSIFICATION_STAGE_DEFAULTS, } from "./claim-type-classification.js";
10
+ export { claimReferenceValidationStage, validateClaimReferences, CLAIM_REFERENCE_FAILURE_CODES, } from "./claim-reference-validation.js";
11
+ export { variableAssignmentStage, assignVariables, isValidVariableSymbol, } from "./variable-assignment.js";
12
+ export { relationExtractionStage, createRelationExtractionStage, RELATION_EXTRACTION_STAGE_DEFAULTS, } from "./relation-extraction.js";
13
+ export { conclusionSelectionStage, createConclusionSelectionStage, CONCLUSION_SELECTION_STAGE_DEFAULTS, } from "./conclusion-selection.js";
14
+ export { formulaCompilationStage, compileFormulas, FORMULA_COMPILATION_FAILURE_CODES, } from "./formula-compilation.js";
15
+ export { formulaValidationStage, validateFormulas, FORMULA_VALIDATION_FAILURE_CODES, } from "./formula-validation.js";
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/extensions/argument-ingestion/stages/index.ts"],"names":[],"mappings":"AAAA,qDAAqD;AAErD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,cAAc,cAAc,CAAA;AAE5B,OAAO,EACH,iBAAiB,EACjB,uBAAuB,EACvB,8BAA8B,EAC9B,2BAA2B,GAC9B,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EACH,2BAA2B,EAC3B,iCAAiC,EACjC,uCAAuC,GAC1C,MAAM,+BAA+B,CAAA;AACtC,OAAO,EACH,4BAA4B,EAC5B,kCAAkC,EAClC,wCAAwC,GAC3C,MAAM,gCAAgC,CAAA;AACvC,OAAO,EACH,4BAA4B,EAC5B,kCAAkC,EAClC,wCAAwC,GAC3C,MAAM,gCAAgC,CAAA;AACvC,OAAO,EACH,gCAAgC,EAChC,qCAAqC,GACxC,MAAM,6BAA6B,CAAA;AACpC,OAAO,EACH,4BAA4B,EAC5B,kCAAkC,EAClC,wCAAwC,GAC3C,MAAM,gCAAgC,CAAA;AACvC,OAAO,EACH,6BAA6B,EAC7B,uBAAuB,EACvB,6BAA6B,GAChC,MAAM,iCAAiC,CAAA;AACxC,OAAO,EACH,uBAAuB,EACvB,eAAe,EACf,qBAAqB,GACxB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EACH,uBAAuB,EACvB,6BAA6B,EAC7B,kCAAkC,GACrC,MAAM,0BAA0B,CAAA;AACjC,OAAO,EACH,wBAAwB,EACxB,8BAA8B,EAC9B,mCAAmC,GACtC,MAAM,2BAA2B,CAAA;AAClC,OAAO,EACH,uBAAuB,EACvB,eAAe,EACf,iCAAiC,GACpC,MAAM,0BAA0B,CAAA;AACjC,OAAO,EACH,sBAAsB,EACtB,gBAAgB,EAChB,gCAAgC,GACnC,MAAM,yBAAyB,CAAA"}
@@ -0,0 +1,13 @@
1
+ import { type TRelationExtractionOutput } from "./schemas.js";
2
+ import type { TStage } from "../../../lib/pipelines/types.js";
3
+ import type { TLlmStageOptionsOverride } from "../shared/types.js";
4
+ export declare const RELATION_EXTRACTION_MODEL = "gpt-5.5";
5
+ export declare const RELATION_EXTRACTION_REASONING: "minimal" | "low" | "medium" | "high";
6
+ export declare const RELATION_EXTRACTION_SYSTEM_PROMPT = "You identify support relationships between canonical claims in an argument.\n\nGiven the canonical claim set, the per-claim type map, and the original segments, emit one entry per supporting relationship. Return an object with a single key `relations` whose value is the array. There are three relation kinds:\n\n- `\"support\"` \u2014 a single claim S supports another claim T. Use this for ordinary \"P, therefore Q\" support edges where the supporting evidence is a single normal-typed proposition.\n- `\"joint-support\"` \u2014 multiple claims S1, S2, ... jointly support T. Use this when the author commits to a syllogistic step that requires ALL of the sources to hold (e.g. major premise + minor premise \u2192 conclusion).\n- `\"derivation-support\"` \u2014 a citation-typed or axiomatic-typed claim S supports a normal-typed claim T. Use this exclusively for relations whose source is \"citation\" or \"axiomatic\". The shape is otherwise identical to `\"support\"`.\n\nFor each relation emit:\n- a fresh `relationId` (r1, r2, ...)\n- the `type`\n- `sources` \u2014 an array of supporting claim miniIds (length 1 for support and derivation-support; length \u2265 2 for joint-support)\n- `target` \u2014 the supported claim's miniId\n- `evidence.segmentIds` \u2014 the segments that ground the relation (often a single segment containing a \"therefore\", \"so\", \"because\")\n- `evidence.quote` \u2014 a short verbatim quote from the input that justifies the relation\n\n## Conservatism rules\n\n- Do not invent relations. If the author doesn't actually argue from S to T, don't emit a relation between them.\n- Do not double-count. If two claims share an axiomatic backing, that's one derivation-support relation per claim, not a joint-support pair.\n- The conclusion of the argument is identified in a separate stage; do NOT emit a special \"conclusion\" relation here. Just emit the support edges you see; the conclusion stage selects from your output.\n- Avoid attack/rebuttal relations entirely in this MVP \u2014 the pipeline does not yet handle them.\n\nIf there are no relations to emit, return `{ \"relations\": [] }`.";
7
+ /** Internal default knobs for the relation-extraction stage. */
8
+ export declare const RELATION_EXTRACTION_STAGE_DEFAULTS: TLlmStageOptionsOverride;
9
+ /** Build the relation-extraction stage with optional caller overrides. */
10
+ export declare function createRelationExtractionStage(options?: TLlmStageOptionsOverride): TStage<TRelationExtractionOutput>;
11
+ /** Backward-compatible default-options stage. */
12
+ export declare const relationExtractionStage: TStage<TRelationExtractionOutput>;
13
+ //# sourceMappingURL=relation-extraction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relation-extraction.d.ts","sourceRoot":"","sources":["../../../../src/extensions/argument-ingestion/stages/relation-extraction.ts"],"names":[],"mappings":"AASA,OAAO,EAMH,KAAK,yBAAyB,EAEjC,MAAM,cAAc,CAAA;AAErB,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,iCAAiC,CAAA;AAC5E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAA;AAElE,eAAO,MAAM,yBAAyB,YAAY,CAAA;AAClD,eAAO,MAAM,6BAA6B,EACpC,SAAS,GACT,KAAK,GACL,QAAQ,GACR,MAAe,CAAA;AAErB,eAAO,MAAM,iCAAiC,6lEAuBqB,CAAA;AAuCnE,gEAAgE;AAChE,eAAO,MAAM,kCAAkC,EAAE,wBAEhD,CAAA;AAED,0EAA0E;AAC1E,wBAAgB,6BAA6B,CACzC,OAAO,CAAC,EAAE,wBAAwB,GACnC,MAAM,CAAC,yBAAyB,CAAC,CAenC;AAED,iDAAiD;AACjD,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAAC,yBAAyB,CACnC,CAAA"}
@@ -0,0 +1,87 @@
1
+ // `relation-extraction` — strong-reasoning stage that identifies the
2
+ // supporting relationships between canonical claims. MVP relation
3
+ // types: support, joint-support, derivation-support.
4
+ //
5
+ // Per spec §6.4 this stage uses gpt-5.5 with reasoning_effort=high —
6
+ // it's the most subtle judgement call in the pipeline. The output is
7
+ // a graph; the conclusion + the support graph drive the
8
+ // formula-compilation stage that comes next.
9
+ import { STAGE_IDS, RelationExtractionOutputSchema, } from "./schemas.js";
10
+ import { llmStage } from "../../../lib/pipelines/stage-helpers.js";
11
+ export const RELATION_EXTRACTION_MODEL = "gpt-5.5";
12
+ export const RELATION_EXTRACTION_REASONING = "high";
13
+ export const RELATION_EXTRACTION_SYSTEM_PROMPT = `You identify support relationships between canonical claims in an argument.
14
+
15
+ Given the canonical claim set, the per-claim type map, and the original segments, emit one entry per supporting relationship. Return an object with a single key \`relations\` whose value is the array. There are three relation kinds:
16
+
17
+ - \`"support"\` — a single claim S supports another claim T. Use this for ordinary "P, therefore Q" support edges where the supporting evidence is a single normal-typed proposition.
18
+ - \`"joint-support"\` — multiple claims S1, S2, ... jointly support T. Use this when the author commits to a syllogistic step that requires ALL of the sources to hold (e.g. major premise + minor premise → conclusion).
19
+ - \`"derivation-support"\` — a citation-typed or axiomatic-typed claim S supports a normal-typed claim T. Use this exclusively for relations whose source is "citation" or "axiomatic". The shape is otherwise identical to \`"support"\`.
20
+
21
+ For each relation emit:
22
+ - a fresh \`relationId\` (r1, r2, ...)
23
+ - the \`type\`
24
+ - \`sources\` — an array of supporting claim miniIds (length 1 for support and derivation-support; length ≥ 2 for joint-support)
25
+ - \`target\` — the supported claim's miniId
26
+ - \`evidence.segmentIds\` — the segments that ground the relation (often a single segment containing a "therefore", "so", "because")
27
+ - \`evidence.quote\` — a short verbatim quote from the input that justifies the relation
28
+
29
+ ## Conservatism rules
30
+
31
+ - Do not invent relations. If the author doesn't actually argue from S to T, don't emit a relation between them.
32
+ - Do not double-count. If two claims share an axiomatic backing, that's one derivation-support relation per claim, not a joint-support pair.
33
+ - The conclusion of the argument is identified in a separate stage; do NOT emit a special "conclusion" relation here. Just emit the support edges you see; the conclusion stage selects from your output.
34
+ - Avoid attack/rebuttal relations entirely in this MVP — the pipeline does not yet handle them.
35
+
36
+ If there are no relations to emit, return \`{ "relations": [] }\`.`;
37
+ function buildPrompt(ctx) {
38
+ const canon = ctx.get(STAGE_IDS.claimCanonicalization);
39
+ const typeEnvelope = ctx.get(STAGE_IDS.claimTypeClassification);
40
+ const typeByMiniId = new Map();
41
+ for (const entry of typeEnvelope?.classifications ?? []) {
42
+ typeByMiniId.set(entry.miniId, entry);
43
+ }
44
+ const segmentEnvelope = ctx.get(STAGE_IDS.segmentation);
45
+ const segments = segmentEnvelope?.segments ?? [];
46
+ const claimLines = (canon?.canonicalClaims ?? [])
47
+ .map((c) => {
48
+ const refinedType = typeByMiniId.get(c.miniId)?.type ?? c.type;
49
+ return ` [${c.miniId}] type=${refinedType} symbol=${c.suggestedSymbol} fields=${JSON.stringify({
50
+ ...c,
51
+ miniId: undefined,
52
+ mentionIds: undefined,
53
+ suggestedSymbol: undefined,
54
+ type: undefined,
55
+ })}`;
56
+ })
57
+ .join("\n");
58
+ const segmentLines = segments
59
+ .map((s) => ` [${s.segmentId}] ${JSON.stringify(s.text)}`)
60
+ .join("\n");
61
+ const markedSystem = `<!-- stage-id: ${STAGE_IDS.relationExtraction} -->\n${RELATION_EXTRACTION_SYSTEM_PROMPT}`;
62
+ const user = `Canonical claims (with refined types):\n${claimLines}\n\nSegments:\n${segmentLines}\n\nEmit every support relationship as a relations array.`;
63
+ return { system: markedSystem, user };
64
+ }
65
+ /** Internal default knobs for the relation-extraction stage. */
66
+ export const RELATION_EXTRACTION_STAGE_DEFAULTS = {
67
+ reasoningEffort: RELATION_EXTRACTION_REASONING,
68
+ };
69
+ /** Build the relation-extraction stage with optional caller overrides. */
70
+ export function createRelationExtractionStage(options) {
71
+ return llmStage({
72
+ id: STAGE_IDS.relationExtraction,
73
+ dependsOn: [
74
+ STAGE_IDS.claimCanonicalization,
75
+ STAGE_IDS.claimTypeClassification,
76
+ STAGE_IDS.segmentation,
77
+ ],
78
+ outputSchema: RelationExtractionOutputSchema,
79
+ model: RELATION_EXTRACTION_MODEL,
80
+ maxOutputTokens: options?.maxOutputTokens,
81
+ reasoningEffort: options?.reasoningEffort ?? RELATION_EXTRACTION_REASONING,
82
+ buildPrompt,
83
+ });
84
+ }
85
+ /** Backward-compatible default-options stage. */
86
+ export const relationExtractionStage = createRelationExtractionStage();
87
+ //# sourceMappingURL=relation-extraction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relation-extraction.js","sourceRoot":"","sources":["../../../../src/extensions/argument-ingestion/stages/relation-extraction.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,kEAAkE;AAClE,qDAAqD;AACrD,EAAE;AACF,qEAAqE;AACrE,qEAAqE;AACrE,wDAAwD;AACxD,6CAA6C;AAE7C,OAAO,EACH,SAAS,EACT,8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