Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions modules/encounter_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,32 @@ def adaptive_intake_plan():
"""
payload = request.get_json(silent=True) or {}
project = payload.get("project", payload) if isinstance(payload, dict) else {}
plan = build_intake_plan(project or {})
project = project if isinstance(project, dict) else {}
plan = build_intake_plan(project)
plan["conditional"] = []
plan["rationale"] = "SafeBARS uses the six core protocol questions; AI review runs automatically after submission."
return jsonify({"success": True, **plan})


@encounter_api.post("/sessions")
def create_session():
try:
encounter_session = encounter_engine.create_session(request.get_json(silent=True) or {})
raw_payload = request.get_json(silent=True) or {}
payload = raw_payload if isinstance(raw_payload, dict) else {}
project = payload.get("project", {})
project = project if isinstance(project, dict) else {}
artifacts = payload.get("artifacts", {})
artifacts = artifacts if isinstance(artifacts, dict) else {}
payload = {
**payload,
"project": {**project, "uses_ai": True},
"artifacts": {
key: value for key, value in artifacts.items()
if key != "ai_governance"
},
"use_llm": True,
}
encounter_session = encounter_engine.create_session(payload)
except ValueError as exc:
return jsonify({"success": False, "error": str(exc)}), 400
except Exception as exc:
Expand Down
13 changes: 8 additions & 5 deletions modules/encounter_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,11 +780,14 @@ def create_protocol_version(self, session_id: str) -> Optional[Dict[str, Any]]:
)
current_version = int(source.get("lineage", {}).get("version_number", 1) or 1)
payload = {
"project": source.get("project", {}),
"artifacts": source.get("artifacts", {}),
"project": {**source.get("project", {}), "uses_ai": True},
"artifacts": {
**source.get("artifacts", {}),
"ai_governance": "",
},
"intake_transcript": source.get("intake_transcript", []),
"selected_scenarios": source.get("selected_scenarios", []),
"use_llm": source.get("use_llm", False),
"use_llm": True,
"application_profile_id": source.get("application_profile_id", ""),
"tradeoff_deliberations": source.get("tradeoff_deliberations", {}),
"lineage": {
Expand Down Expand Up @@ -1464,9 +1467,9 @@ def _build_audit_plan(
"title": "Probe for additional passage-grounded gaps",
"goal": "Find at most two non-checklist gaps while remaining grounded to submitted passages.",
"reason": (
"A provider is configured and the researcher enabled this optional probe."
"The always-on AI review path found a configured provider for this bounded probe."
if llm_enabled
else "Skipped because no configured provider was enabled; deterministic tracing remains active."
else "The AI critic was requested automatically, but no provider is configured; deterministic tracing remains active."
),
"priority": "low",
"status": "queued" if llm_enabled else "skipped",
Expand Down
22 changes: 12 additions & 10 deletions modules/encounter_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -857,11 +857,12 @@ def build_ethics_application_docx(session: Dict[str, Any]) -> bytes:
if project.get("uses_ai") or assessment.get("uses_ai"):
document.add_heading("7. AI use and risk-management appendix", level=1)
_add_label_paragraph(document, "AI role described by researcher", project.get("context"))
_add_label_paragraph(
document,
"Submitted AI ethics-review supplement",
artifacts.get("ai_governance"),
)
if str(artifacts.get("ai_governance", "")).strip():
_add_label_paragraph(
document,
"Legacy AI governance notes",
artifacts.get("ai_governance"),
)
_add_label_paragraph(
document,
"Review basis",
Expand Down Expand Up @@ -1041,11 +1042,12 @@ def build_research_design_docx(session: Dict[str, Any]) -> bytes:
if project.get("uses_ai") or assessment.get("uses_ai"):
document.add_heading("7. AI role, human oversight, and failure response", level=1)
_add_label_paragraph(document, "Submitted AI role", project.get("context"))
_add_label_paragraph(
document,
"Submitted AI ethics-review supplement",
artifacts.get("ai_governance"),
)
if str(artifacts.get("ai_governance", "")).strip():
_add_label_paragraph(
document,
"Legacy AI governance notes",
artifacts.get("ai_governance"),
)
_add_label_paragraph(
document,
"Design basis",
Expand Down
Loading
Loading