Skip to content

feat(comprehension): ingestion-time LLM digests so ask/chat answer structure + combination questions - #1158

Open
northdpole wants to merge 52 commits into
claude/fix-agent-index-80b1a2from
feat/ingest-comprehension
Open

northdpole wants to merge 52 commits into
claude/fix-agent-index-80b1a2from
feat/ingest-comprehension

Conversation

@northdpole

Copy link
Copy Markdown
Collaborator

Stacked on #1155.

Why

#1155 answered structural questions (e.g. SAMM levels) from hand-written facts, which cannot scale and was partly wrong. This derives that knowledge at ingestion instead.

How

  • application/utils/comprehension/: reads whole harvested documents, extracts claims that must include a verbatim quote found in the source (unverified claims dropped), builds a per-standard overview that must cite existing documents, and stores everything as embedded evidence docs in the existing agent channel.
  • Query time: router hook synthesizes an answer from the top comprehension hits with citations; UNKNOWN falls through to existing paths. Flag: OWASP_COMPREHENSION_ENABLED (default on).
  • scripts/comprehend_standard.py --repo OWASP/SAMM runs it per harvested repo.
  • Design note: docs/oie/comprehension-design.md.

Verified on staging (homeserver)

SAMM/ASVS/MASVS/AI guide digested; e.g. "how many levels in owasp samm" returns three maturity levels per practice (also surfaces a v1.5 vs v2 conflict, to fix by preferring the latest version), with GitHub citations.

Not done yet

Generated source-grounded eval (Gemini questions, Claude judge), held-out standard test, version preference, removal of hand-written node_facts, people/talks layer, scheduling into the pipeline.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review: 1
  • main

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@northdpole
northdpole force-pushed the fix/ask-embedding-retrieval branch from 21890d0 to 1129c1f Compare October 20, 2026 08:20
@northdpole
northdpole force-pushed the feat/ingest-comprehension branch from 016ec56 to 2972c67 Compare October 20, 2026 08:20
@northdpole
northdpole changed the base branch from fix/ask-embedding-retrieval to claude/fix-agent-index-80b1a2 October 20, 2026 08:21
@northdpole
northdpole force-pushed the claude/fix-agent-index-80b1a2 branch from 7dd9cd2 to f5ba231 Compare October 20, 2026 08:29
@northdpole
northdpole force-pushed the feat/ingest-comprehension branch from 2972c67 to 8306880 Compare October 20, 2026 08:29
@northdpole
northdpole force-pushed the claude/fix-agent-index-80b1a2 branch from f5ba231 to d14089a Compare October 20, 2026 08:48
@northdpole
northdpole force-pushed the feat/ingest-comprehension branch from 8306880 to 5860a9d Compare October 20, 2026 08:48
@northdpole
northdpole force-pushed the claude/fix-agent-index-80b1a2 branch from d14089a to cb51c1f Compare October 20, 2026 09:21
@northdpole
northdpole force-pushed the feat/ingest-comprehension branch from c306180 to 6b2c573 Compare October 20, 2026 09:21
@northdpole
northdpole force-pushed the feat/ingest-comprehension branch from b6ded96 to 0a34ae0 Compare October 21, 2026 21:09
@northdpole
northdpole force-pushed the claude/fix-agent-index-80b1a2 branch from cb51c1f to fe62660 Compare October 21, 2026 23:09
@northdpole
northdpole force-pushed the feat/ingest-comprehension branch 2 times, most recently from c4b23d4 to 594e1d0 Compare October 22, 2026 07:59
@northdpole
northdpole force-pushed the claude/fix-agent-index-80b1a2 branch from fe62660 to 044e610 Compare October 22, 2026 07:59
@northdpole
northdpole marked this pull request as ready for review October 22, 2026 11:17
northdpole and others added 9 commits October 25, 2026 10:31
…es at ingestion

Replace hand-curated structural facts with LLM comprehension of harvested
standards. Per-document claims must carry a verbatim quote found in the source;
a per-standard overview must cite existing documents. Results are embedded as
evidence docs in the existing agent channel; at query time the router
synthesizes an answer from the top comprehension hits and strips uncited
output (UNKNOWN falls through).

- application/utils/comprehension: sources, digest, store, synthesize, answer
- scripts/comprehend_standard.py: run for one harvested repo
- router hook behind OWASP_COMPREHENSION_ENABLED (default on)
- design note: docs/oie/comprehension-design.md

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…, prefer latest version, overview-first ordering

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…hesis is UNKNOWN; sharper synthesis rules

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…row abstain to non-CRE questions

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…artially instead of abstaining

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
northdpole and others added 28 commits October 25, 2026 10:31
…dings (and merge the two heads)

Vector search was a full scan; the index is used when OWASP_PGVECTOR_HALFVEC=1.
No-op on SQLite and without the vector extension.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…roject questions (L4)

Flagged off by default. Falls back to normal retrieval when the question names no
single project, the project is too big, or the answer is unknown.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… winning flag set

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…_CX_LONGCTX_PROJECTS)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…nd OWASP_CX_DECOMPOSE (multi-part questions)

Both off by default; measured before being turned on.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ed lower)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…inking budget

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The async tool handler called the blocking ask directly on the event loop with a single
worker, so concurrent users were answered one after another (3 parallel users saw ~3x
the single-user latency). Each call now runs in a thread with its own Flask app context.
OPENCRE_MCP_ASK_CONCURRENCY caps threads (default 8).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…concurrency cap

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The first question after a restart took ~30 s (imports, embedding client, database connection).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…stion names

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…imilarity when none is named

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… skipped

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…w fit)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…comprehend_standard

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…incremental

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…s 90 s on a 250-chunk repo)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…art and cross-standard questions

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… get, overview of indexed sources)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…slices, so a provider outage no longer discards a repo's enrichment

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…estions (off by default)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…wers per standard (off by default)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…s and issue titles as retrievable documents

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… per OWASP YouTube talk)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…skips the record Nest cannot serialise

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@northdpole
northdpole force-pushed the claude/fix-agent-index-80b1a2 branch from 044e610 to f6c15e0 Compare October 25, 2026 10:35
@northdpole
northdpole force-pushed the feat/ingest-comprehension branch from 5406406 to 4c92743 Compare October 25, 2026 10:35

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant