refactor(confidence-engine): extract focused deconstruction seam
This commit is contained in:
@@ -189,4 +189,55 @@ export function validateFocusedDeconstructSchema(result) {
|
||||
return errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compose a focused answer deconstruction invocation.
|
||||
*
|
||||
* Accepts explicit provider and modelName — does NOT call getProvider or getProviderModelName.
|
||||
* Calls buildFocusedDeconstructPrompt internally to produce the prompt.
|
||||
* Calls provider.generateReconstruction exactly once.
|
||||
* Validates result with validateFocusedDeconstructSchema.
|
||||
* Returns validated semantic payload on success, or { validation: false, errors } on schema failure.
|
||||
*/
|
||||
export function focusedDeconstruct({
|
||||
provider,
|
||||
modelName,
|
||||
targetNodeId,
|
||||
targetLabel,
|
||||
targetDescription,
|
||||
centralStatement,
|
||||
question,
|
||||
answer,
|
||||
}) {
|
||||
const prompt = buildFocusedDeconstructPrompt({
|
||||
targetLabel,
|
||||
targetDescription,
|
||||
centralStatement,
|
||||
question,
|
||||
answer,
|
||||
});
|
||||
|
||||
const wrapper = provider.generateReconstruction(
|
||||
prompt,
|
||||
modelName,
|
||||
focusedDeconstructJsonSchema,
|
||||
);
|
||||
|
||||
const deconstruction = wrapper.response;
|
||||
|
||||
const validationErrors = validateFocusedDeconstructSchema(deconstruction);
|
||||
if (validationErrors.length > 0) {
|
||||
return { success: false, validation: false, errors: validationErrors };
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
targetNodeId,
|
||||
observations: deconstruction.observations,
|
||||
uncertainties: deconstruction.uncertainties,
|
||||
assumptions: deconstruction.assumptions,
|
||||
relationships: deconstruction.relationships,
|
||||
possibleFollowUpQuestions: deconstruction.possibleFollowUpQuestions,
|
||||
};
|
||||
}
|
||||
|
||||
export { FOCUSED_ANSWER_SCHEMA_FIELDS, FORBIDDEN_GRAPH_MUTATION_FIELDS };
|
||||
|
||||
Reference in New Issue
Block a user