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
7 changes: 7 additions & 0 deletions CHANGELOG.d/2.12.7-korean-search-boundary.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# 2.12.7 — Preserve Korean search corroboration boundaries

## Fixed

- Accept a Korean organization token followed by a grammatical particle in a
natural Searxng snippet while still rejecting the token inside a longer
unrelated Hangul word.
50 changes: 23 additions & 27 deletions backend/app/analysis_run_start.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import hashlib
import json
from datetime import datetime, timezone
from datetime import UTC, datetime
from typing import Any
from uuid import UUID

Expand All @@ -21,15 +21,15 @@
AnalysisRunCreateError,
fetch_visible_analysis_run,
)
from backend.app.post_eligibility import SOURCE_POST_ELIGIBILITY_SQL
from backend.app.analysis_run_outbox import (
latest_outbox_delivery_is_claimed,
latest_outbox_delivery_is_delivered,
outbox_request_digest,
)
from backend.app.lineage_ingestion import records_from_source_posts
from backend.app.post_eligibility import SOURCE_POST_ELIGIBILITY_SQL
from lineageweave.adjudication_client import AdjudicationClient
from lineageweave.http_client import HttpClientError, post_json
from lineageweave.http_client import post_json
from lineageweave.lineage_persistence import lineage_edge_specs
from lineageweave.models import Edge
from lineageweave.tepp_client import AnalysisRunRequest, TeppClient, TeppNotAvailable
Expand Down Expand Up @@ -103,8 +103,8 @@ def transport(payload: dict[str, Any]) -> dict[str, Any]:
try:
headers = {"authorization": f"Bearer {api_key}"} if api_key.strip() else {}
return post_json(url, payload, headers=headers, timeout=30.0)
except (HttpClientError, OSError, ValueError, TypeError) as exc:
raise TeppNotAvailable("TEPP transport unavailable") from exc
except Exception as exc:
raise TeppNotAvailable("TEPP transport request failed") from exc

return TeppClient(transport=transport)

Expand All @@ -119,12 +119,12 @@ def tepp_run_request(
"""Build TEPP's published request from the frozen run, never a theta."""
cutoff = knowledge_cutoff
if cutoff.tzinfo is None:
cutoff = cutoff.replace(tzinfo=timezone.utc)
cutoff = cutoff.replace(tzinfo=UTC)
return AnalysisRunRequest(
idempotency_key=idempotency_key,
tenant_workspace_id=str(corporate_entity_id),
snapshot_id=snapshot_sha256,
knowledge_cutoff=cutoff.astimezone(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ"),
knowledge_cutoff=cutoff.astimezone(UTC).strftime("%Y-%m-%dT%H:%M:%SZ"),
model_contract_version=_TEPP_MODEL_CONTRACT,
output_profile=_TEPP_OUTPUT_PROFILE,
)
Expand Down Expand Up @@ -610,7 +610,7 @@ async def deliver_queued_analysis_run(
return await _visible_or_404(
conn, analysis_run_id, account_id, affiliated_entity_ids
)
now = datetime.now(timezone.utc)
now = datetime.now(UTC)
try:
if not latest_outbox_delivery_is_claimed(latest):
await _append_outbox_delivery(
Expand All @@ -636,9 +636,8 @@ async def deliver_queued_analysis_run(
affiliated_entity_ids=affiliated_entity_ids,
adjudication_client=adjudication_client,
)
finished = datetime.now(timezone.utc)
if finished < now:
finished = now
finished = datetime.now(UTC)
finished = max(finished, now)
await _append_outbox_delivery(
conn,
analysis_run_id,
Expand Down Expand Up @@ -699,7 +698,7 @@ async def _deliver_lineage_reconstruction(
adjudication_client: AdjudicationClient | None = None,
) -> None:
"""Persist ThreadWeave parent choices for the frozen bag."""
now = datetime.now(timezone.utc)
now = datetime.now(UTC)
member_rows = await _snapshot_member_posts(
conn,
locked["analysis_source_snapshot_id"],
Expand All @@ -715,9 +714,8 @@ async def _deliver_lineage_reconstruction(
)
edges = lineage_edge_specs(records_from_source_posts(rows), llm=adjudication_client)
digest = reconstruction_result_digest(edges)
finished = datetime.now(timezone.utc)
if finished < now:
finished = now
finished = datetime.now(UTC)
finished = max(finished, now)
await conn.execute(
"""
insert into analysis_run_reconstruction
Expand Down Expand Up @@ -759,25 +757,23 @@ async def _deliver_tepp_measurement(
tepp_client: TeppClient,
) -> None:
"""Submit the frozen snapshot through ``tepp_client``. Never persist a theta."""
now = datetime.now(timezone.utc)
now = datetime.now(UTC)
request = tepp_run_request(
idempotency_key=str(locked["idempotency_key"]),
snapshot_sha256=str(locked["snapshot_sha256"]),
knowledge_cutoff=locked["knowledge_cutoff"],
corporate_entity_id=str(locked["corporate_entity_id"]),
)
status_code, failure_code, envelope = _tepp_submission(tepp_client, request)
if status_code == _SUCCEEDED and envelope is not None:
if not await _persist_tepp_result(
conn,
analysis_run_id=analysis_run_id,
envelope=envelope,
):
status_code = _FAILED
failure_code = "tepp_result_not_persisted"
finished = datetime.now(timezone.utc)
if finished < now:
finished = now
if status_code == _SUCCEEDED and envelope is not None and not await _persist_tepp_result(
conn,
analysis_run_id=analysis_run_id,
envelope=envelope,
):
status_code = _FAILED
failure_code = "tepp_result_not_persisted"
finished = datetime.now(UTC)
finished = max(finished, now)
await _append_status(
conn,
analysis_run_id,
Expand Down
6 changes: 6 additions & 0 deletions docs/adr/0005-relation-verification-agent.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ keeps the channel unavailable (never fabricates a verification result)
when `SEARXNG_BASE_URL` is unset, same discipline as every other
pluggable client in this repo.

Evidence token selection excludes generic fixture descriptors such as
`fictitious`, `nonexistent`, `placeholder`, `sample`, `example`, and `demo`.
Those words can appear in unrelated search results and are not organization
identity. This keeps synthetic demo data out of the corroboration signal while
retaining distinctive organization tokens and cited URLs.

Persistence: `post_counterparty_entity` gains
`verification_status_code` (`common_lookup_value` category
`relation_verification_status`: `verify_pending` / `verify_corroborated`
Expand Down
6 changes: 6 additions & 0 deletions docs/adr/0022-authorized-tepp-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ authorized transaction:
4. submits through `TeppClient`. An empty `TEPP_TRANSPORT_URL` keeps the
default unavailable transport. A set URL POSTs the published wire
payload through the http(s)-only helper. File URLs stay unavailable;
`AnalysisRunRequest` rejects non-v1 versions and blank/non-text required
fields before the transport is called, matching TEPP's v1 JSON Schema;
5. appends Failed / `tepp_not_available` when the transport is missing
or refused, or Failed / `tepp_result_not_persisted` when TEPP accepts
an envelope this product cannot store yet.
Expand Down Expand Up @@ -93,3 +95,7 @@ World Wide Web Consortium. https://www.w3.org/TR/prov-dm/

World Wide Web Consortium. (2013). *PROV-O: The PROV ontology* (W3C
Recommendation). https://www.w3.org/TR/prov-o/

ContextualWisdomLab. (2026). *TEPP API and modular integration contract*
([Computer software documentation]). GitHub.
https://github.com/ContextualWisdomLab/TEPP/blob/main/docs/API_CONTRACT.md
Loading