AI Narrative Adapter¶
Purpose¶
The AI narrative adapter converts a controlled package of canonical QLens research into a traceable publication draft. It MUST NOT create, revise, verify, or supersede canonical research objects.
Required boundary¶
- QLens MUST resolve every
source_oidbefore an AI request. - Only permitted research-object types from the publication's Research Space MAY enter the context package.
- The provider MUST receive the publication contract, source records, statuses, versions, and a deterministic context digest.
- Every generated section MUST cite one or more permitted source OIDs.
- QLens MUST validate the structured response before writing a draft.
- AI output MUST enter
needs_review; it MUST NOT become public automatically. - API credentials MUST remain outside canonical YAML, generated files, browser JavaScript, and NUR pages.
Provider independence¶
NarrativeProvider is the stable interface. OpenAI is supplied as an optional adapter. A deterministic mock provider is available for tests and offline development.
Artifacts¶
Each AI revision produces:
- structured JSON;
- traceable Markdown;
- the exact source-context JSON;
- an immutable
PublicationAIDraftGeneratedevent.
Failure conditions¶
Generation fails when a source is missing, outside the Research Space, of an unsupported type, or when the response contains an unknown OID, an untraceable section, or language that incorrectly upgrades provisional research.