213 lines
11 KiB
JavaScript
213 lines
11 KiB
JavaScript
/**
|
|
* Durable narrow frontier prompt builders (EXP42).
|
|
*
|
|
* Two prompt-building functions that share one frontier-rule source,
|
|
* one context formatter, and one JSON-only anchoring instruction.
|
|
*
|
|
* This file is experimental apparatus only. It is NOT production code.
|
|
*/
|
|
|
|
// ── shared constants ───────────────────────────────────────────────────────
|
|
|
|
const FRONTIER_RULES = `Identify the single nearest thing that is still unknown because of this answer.
|
|
|
|
Find the smallest thing we actually do not know yet.
|
|
|
|
Return exactly one uncertainty.
|
|
|
|
Return exactly one follow-up question.
|
|
|
|
The question must directly investigate that uncertainty.
|
|
|
|
Do not jump to what might matter later.
|
|
|
|
Do not move to another branch before this one is understood.
|
|
|
|
Do not assume an explanation, deficit, cause, requirement, intervention, or solution that has not been established.
|
|
|
|
If a proposition has not been established, test whether it is true rather than assuming it.
|
|
|
|
One question must investigate one thing only.
|
|
|
|
Use ordinary language a capable non-expert can understand immediately.`;
|
|
|
|
const JSON_ONLY_INSTRUCTION = `Return exactly one JSON object.
|
|
Return JSON only.
|
|
Do not include prose, markdown, headings, commentary, or explanation outside the JSON object.`;
|
|
|
|
function formatContext({ centralStatement, targetLabel, targetDescription, question, answer }) {
|
|
return [
|
|
"Central situation:",
|
|
centralStatement,
|
|
"",
|
|
"Focused target:",
|
|
targetLabel,
|
|
"",
|
|
"Target description:",
|
|
targetDescription,
|
|
"",
|
|
"Question asked:",
|
|
question,
|
|
"",
|
|
"User answer:",
|
|
answer,
|
|
].join("\n");
|
|
}
|
|
|
|
// ── builders ───────────────────────────────────────────────────────────────
|
|
|
|
/**
|
|
* Build the minimal (two-field) frontier prompt.
|
|
* Semantic workload: one uncertainty + one follow-up question.
|
|
*/
|
|
export function buildMinimalFrontierPrompt({ centralStatement, targetLabel, targetDescription, question, answer }) {
|
|
return [
|
|
JSON_ONLY_INSTRUCTION,
|
|
"",
|
|
"Required top-level fields:",
|
|
"- uncertainties",
|
|
"- possibleFollowUpQuestions",
|
|
"",
|
|
"Return this exact shape:",
|
|
'{"uncertainties": ["one uncertainty"], "possibleFollowUpQuestions": ["one follow-up question"]}',
|
|
"",
|
|
FRONTIER_RULES,
|
|
"",
|
|
"Focused case context:",
|
|
formatContext({ centralStatement, targetLabel, targetDescription, question, answer }),
|
|
].join("\n");
|
|
}
|
|
|
|
/**
|
|
* Build the observation-grounded frontier prompt.
|
|
* Semantic workload: observations + one uncertainty + one follow-up question.
|
|
*/
|
|
export function buildObservationFrontierPrompt({ centralStatement, targetLabel, targetDescription, question, answer }) {
|
|
return [
|
|
JSON_ONLY_INSTRUCTION,
|
|
"",
|
|
"Required top-level fields:",
|
|
"- observations",
|
|
"- uncertainties",
|
|
"- possibleFollowUpQuestions",
|
|
"",
|
|
"Return this exact shape:",
|
|
'{"observations": ["one or more directly supported observations"], "uncertainties": ["one uncertainty"], "possibleFollowUpQuestions": ["one follow-up question"]}',
|
|
"",
|
|
`observations: only meaning directly supported by what the user's answer states. Do not strengthen implications into observations.`,
|
|
"",
|
|
FRONTIER_RULES,
|
|
"",
|
|
"Focused case context:",
|
|
formatContext({ centralStatement, targetLabel, targetDescription, question, answer }),
|
|
].join("\n");
|
|
}
|
|
|
|
/**
|
|
* Build the relationship-frontier prompt.
|
|
* Semantic workload: relationships + one uncertainty + one follow-up question.
|
|
*/
|
|
export function buildRelationshipFrontierPrompt({ centralStatement, targetLabel, targetDescription, question, answer }) {
|
|
return [
|
|
JSON_ONLY_INSTRUCTION,
|
|
"",
|
|
"Required top-level fields:",
|
|
"- relationships",
|
|
"- uncertainties",
|
|
"- possibleFollowUpQuestions",
|
|
"",
|
|
"Return this exact shape:",
|
|
'{"relationships": ["one or more directly established relationships"], "uncertainties": ["one uncertainty"], "possibleFollowUpQuestions": ["one follow-up question"]}',
|
|
"",
|
|
`relationships: only connections that the user's answer directly establishes between items. Co-mentioned facts do not by themselves create causal, constraint, or dependency relationships. If a relationship is only plausible, omit it rather than assert it.`,
|
|
"",
|
|
FRONTIER_RULES,
|
|
"",
|
|
"Focused case context:",
|
|
formatContext({ centralStatement, targetLabel, targetDescription, question, answer }),
|
|
].join("\n");
|
|
}
|
|
|
|
/**
|
|
* Build the assumption-frontier prompt.
|
|
* Semantic workload: assumptions + one uncertainty + one follow-up question.
|
|
*/
|
|
export function buildAssumptionFrontierPrompt({ centralStatement, targetLabel, targetDescription, question, answer }) {
|
|
return [
|
|
JSON_ONLY_INSTRUCTION,
|
|
"",
|
|
"Required top-level fields:",
|
|
"- assumptions",
|
|
"- uncertainties",
|
|
"- possibleFollowUpQuestions",
|
|
"",
|
|
"Return this exact shape:",
|
|
'{"assumptions": ["zero or more genuinely user-held assumptions"], "uncertainties": ["one uncertainty"], "possibleFollowUpQuestions": ["one follow-up question"]}',
|
|
"",
|
|
`assumptions: what unstated proposition does the user's answer itself rely upon for it to make sense? Attribute only when such a proposition is genuinely attributable to the user's reasoning. The boundary is narrow: attribute only propositions that the user's answer would cease to make sense if they were false. Do NOT import plausible interpretations from the wider investigation context, scenario framing, domain relevance, strategic implications, or model-generated analysis into this field — those belong in uncertainties, other structured fields where permitted, or possibleFollowUpQuestions. Do NOT connect a factual statement the user makes to a broader capability or constraint concept unless the user explicitly links them. Example: answering "I only have bank account access" to a question about delegation constraints does NOT assume that "delegation feasibility is contingent upon banking access" — it only states a fact about access, and connecting that fact to delegation feasibility is your own scenario-level inference, not a user-held assumption. If the user's answer does not contain or rely upon an identifiable assumption, return assumptions: []. Do NOT require verbatim copying from the user's answer; paraphrasing is allowed only when the reasoning genuinely relies on it.`,
|
|
"",
|
|
FRONTIER_RULES,
|
|
"",
|
|
"Focused case context:",
|
|
formatContext({ centralStatement, targetLabel, targetDescription, question, answer }),
|
|
].join("\n");
|
|
}
|
|
|
|
/**
|
|
* Build the observation+assumption-frontier prompt.
|
|
* Semantic workload: observations + assumptions + one uncertainty + one follow-up question.
|
|
*/
|
|
export function buildObservationAssumptionFrontierPrompt({ centralStatement, targetLabel, targetDescription, question, answer }) {
|
|
return [
|
|
JSON_ONLY_INSTRUCTION,
|
|
"",
|
|
"Required top-level fields:",
|
|
"- observations",
|
|
"- assumptions",
|
|
"- uncertainties",
|
|
"- possibleFollowUpQuestions",
|
|
"",
|
|
"Return this exact shape:",
|
|
'{"observations": ["one or more directly supported observations"], "assumptions": ["zero or more genuinely user-held assumptions"], "uncertainties": ["one uncertainty"], "possibleFollowUpQuestions": ["one follow-up question"]}',
|
|
"",
|
|
`observations: only meaning directly supported by what the user's answer states. Do not strengthen implications into observations.`,
|
|
"",
|
|
`assumptions: what unstated proposition does the user's answer itself rely upon for it to make sense? Attribute only when such a proposition is genuinely attributable to the user's reasoning. The boundary is narrow: attribute only propositions that the user's answer would cease to make sense if they were false. Do NOT import plausible interpretations from the wider investigation context, scenario framing, domain relevance, strategic implications, or model-generated analysis into this field — those belong in uncertainties, other structured fields where permitted, or possibleFollowUpQuestions. Do NOT connect a factual statement the user makes to a broader capability or constraint concept unless the user explicitly links them. Example: answering "I only have bank account access" to a question about delegation constraints does NOT assume that "delegation feasibility is contingent upon banking access" — it only states a fact about access, and connecting that fact to delegation feasibility is your own scenario-level inference, not a user-held assumption. If the user's answer does not contain or rely upon an identifiable assumption, return assumptions: []. Do NOT require verbatim copying from the user's answer; paraphrasing is allowed only when the reasoning genuinely relies on it.`,
|
|
"",
|
|
FRONTIER_RULES,
|
|
"",
|
|
"Focused case context:",
|
|
formatContext({ centralStatement, targetLabel, targetDescription, question, answer }),
|
|
].join("\n");
|
|
}
|
|
|
|
/**
|
|
* Build the observation+strict-assumption-frontier prompt (EXP49).
|
|
* Semantic workload: observations + assumptions + one uncertainty + one follow-up question.
|
|
* Differs from buildObservationAssumptionFrontierPrompt only in the assumption rule,
|
|
* which adds an explicit attribution boundary for co-mentioned / contrasted / juxtaposed facts.
|
|
*/
|
|
export function buildObservationStrictAssumptionFrontierPrompt({ centralStatement, targetLabel, targetDescription, question, answer }) {
|
|
return [
|
|
JSON_ONLY_INSTRUCTION,
|
|
"",
|
|
"Required top-level fields:",
|
|
"- observations",
|
|
"- assumptions",
|
|
"- uncertainties",
|
|
"- possibleFollowUpQuestions",
|
|
"",
|
|
"Return this exact shape:",
|
|
'{"observations": ["one or more directly supported observations"], "assumptions": ["zero or more genuinely user-held assumptions"], "uncertainties": ["one uncertainty"], "possibleFollowUpQuestions": ["one follow-up question"]}',
|
|
"",
|
|
`observations: only meaning directly supported by what the user's answer states. Do not strengthen implications into observations.`,
|
|
"",
|
|
`assumptions: what unstated proposition does the user's answer itself rely upon for it to make sense? Attribute only when such a proposition is genuinely attributable to the user's reasoning. The boundary is narrow: attribute only propositions that the user's answer would cease to make sense if they were false. Do NOT import plausible interpretations from the wider investigation context, scenario framing, domain relevance, strategic implications, or model-generated analysis into this field — those belong in uncertainties, other structured fields where permitted, or possibleFollowUpQuestions. Co-mentioned, contrasted, or juxtaposed facts do not by themselves establish a user-held assumption. Do not invent a proposition merely to explain why two facts can both be true. A proposition belongs in assumptions only if the user's answer itself depends on that proposition for its meaning and would cease to make sense, or materially lose its intended reasoning, if the proposition were false. Otherwise return assumptions: []. If the user's answer does not contain or rely upon an identifiable assumption, return assumptions: []. Do NOT require verbatim copying from the user's answer; paraphrasing is allowed only when the reasoning genuinely relies on it.`,
|
|
"",
|
|
FRONTIER_RULES,
|
|
"",
|
|
"Focused case context:",
|
|
formatContext({ centralStatement, targetLabel, targetDescription, question, answer }),
|
|
].join("\n");
|
|
}
|