Skip to content

docs: README sequence diagram + chatbot learns the architecture#32

Merged
FiscalMindset merged 1 commit into
mainfrom
docs/embed-and-kb
Jul 12, 2026
Merged

docs: README sequence diagram + chatbot learns the architecture#32
FiscalMindset merged 1 commit into
mainfrom
docs/embed-and-kb

Conversation

@FiscalMindset

@FiscalMindset FiscalMindset commented Jul 12, 2026

Copy link
Copy Markdown
Owner

Follow-up to system_design.md:

  • README: embeds a step-by-step proxy-request sequence diagram (collapsible) in 'How Blindfold fixes it', with a pointer to system_design.md's full 11-diagram set.
  • Chatbot: curated KB entries system_architecture + three_secret_paths (linking to system_design.md) with classifier patterns + Intent types. Questions like 'how is Blindfold architected', 'system design', 'three secret paths', 'proxy vs release' now route at conf 1.00.

Co-authored-by: algsoch algsoch@gmail.com


Summary by cubic

Added a step‑by‑step proxy request sequence diagram to the README and taught the chatbot the system architecture so it can answer “how is Blindfold built” and “three secret paths” with accurate routing. This clarifies how the proxy works and improves answers to architecture questions.

  • New Features
    • README: collapsible Mermaid sequence for a single proxy request, with a pointer to the full diagrams in system_design.md.
    • Chatbot: new curated KB entries (system_architecture, three_secret_paths), added intents and patterns in packages/chatbot/src/intents.ts and types in src/types.ts; questions like “system design” and “proxy vs release” now route at confidence 1.00.

Written for commit aadde39. Summary will update on new commits.

Review in cubic

…architecture

- README: add a step-by-step proxy-request sequence diagram (collapsible) in
  'How Blindfold fixes it', linking to system_design.md's full diagram set.
- Chatbot: add curated KB entries system_architecture + three_secret_paths
  (pointing to system_design.md) with classifier patterns + Intent types.
  Verified routing at conf 1.00. (The extract run merged system_design.md to 0
  new entries — its content mapped onto existing intents — so these are curated.)

Co-authored-by: algsoch <algsoch@gmail.com>
@FiscalMindset
FiscalMindset merged commit f3b04ba into main Jul 12, 2026
@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Docs: add proxy sequence diagram + teach chatbot architecture intents

📝 Documentation ✨ Enhancement 🕐 10-20 Minutes

Grey Divider

AI Description

• Embed a collapsible proxy-request mermaid sequence diagram in the README.
• Link README readers to full system_design.md architecture diagram set.
• Add chatbot KB entries and intent patterns for architecture and “three secret paths” questions.
Diagram

sequenceDiagram
    autonumber
    participant A as Agent
    participant P as Local Proxy
    participant E as TDX Enclave
    participant U as Upstream API
    A->>P: HTTP request (Authorization: __BLINDFOLD__)
    P->>E: ForwardRequest (sentinel only)
    E->>U: HTTPS request (real key substituted in-enclave)
    U-->>E: Response
    E-->>P: Response (secret redacted)
    P-->>A: Response (key never leaves enclave)
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Auto-generate architecture KB from docs during build
  • ➕ Reduces drift between docs and chatbot answers
  • ➕ Avoids manual updates to knowledge.json for new architecture sections
  • ➖ Harder to guarantee precise routing/confidence for specific intents
  • ➖ More pipeline complexity and potential for noisy entries
2. Route architecture questions via embedding search over system_design.md
  • ➕ Less brittle than phrase-pattern classification
  • ➕ Scales better as docs grow (fewer explicit intents needed)
  • ➖ Weaker determinism vs explicit intents/patterns
  • ➖ Requires tuning retrieval + response formatting to stay concise and accurate

Recommendation: The PR’s curated KB entries plus explicit intent patterns are the right choice for now because they provide deterministic routing for high-value queries (e.g., “proxy vs release”) and keep answers tightly aligned with the desired explanation and links. Consider adding a generation or embedding-based fallback later for long-tail architecture questions, but keep these curated intents as “golden paths.”

Files changed (4) +114 / -3

Enhancement (3) +91 / -2
knowledge.jsonAdd curated KB entries for system architecture and three secret paths +63/-2

Add curated KB entries for system architecture and three secret paths

• Updates metadata timestamp/source and appends two new knowledge entries: 'system_architecture' and 'three_secret_paths'. Each entry includes short/long answers, source links (notably system_design.md), and verification metadata for high-confidence routing.

packages/chatbot/data/knowledge.json

intents.tsIntroduce intent patterns for architecture and proxy-vs-release questions +26/-0

Introduce intent patterns for architecture and proxy-vs-release questions

• Adds two new intent definitions with weighted phrase patterns and examples to classify architecture/system-design queries and “three secret paths” comparisons. This enables direct routing of common user questions to the new curated KB entries.

packages/chatbot/src/intents.ts

types.tsExtend Intent union with architecture-related intents +2/-0

Extend Intent union with architecture-related intents

• Adds 'system_architecture' and 'three_secret_paths' to the 'Intent' type union so the classifier and KB can reference them in a type-safe way.

packages/chatbot/src/types.ts

Documentation (1) +23 / -1
README.mdAdd collapsible proxy request sequence diagram + link to full design doc +23/-1

Add collapsible proxy request sequence diagram + link to full design doc

• Replaces the single architecture link with a collapsible mermaid sequence diagram illustrating the proxy/forward flow. Adds a pointer to system_design.md as the comprehensive architecture reference while still linking the original architecture writeup.

README.md

@gitar-bot

gitar-bot Bot commented Jul 12, 2026

Copy link
Copy Markdown

Important

You are using the Gitar free plan. Upgrade to unlock code review, CI analysis, auto-apply, custom automations, and more.

Gitar

@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (2) 📘 Rule violations (0) 📜 Skill insights (0)

Context used
✅ Compliance rules (platform): 5 rules
✅ Skills: blindfold

Grey Divider


Remediation recommended

1. Overconfident generic intents 🐞 Bug ≡ Correctness
Description
The new intent patterns include very generic phrases (e.g., "components", "three ways") that are
matched via substring and can yield confidence=1.0 with only a single hit, causing incorrect intent
routing and overly confident answers for minimally-related queries.
Code

packages/chatbot/src/intents.ts[R714-739]

+  {
+    intent: "system_architecture",
+    patterns: [
+      { type: "phrase", value: "system design", weight: 6 },
+      { type: "phrase", value: "architect", weight: 5 },
+      { type: "phrase", value: "design of", weight: 3 },
+      { type: "phrase", value: "how is it built", weight: 4 },
+      { type: "phrase", value: "how is blindfold built", weight: 5 },
+      { type: "phrase", value: "how does the whole system", weight: 5 },
+      { type: "phrase", value: "components", weight: 2 },
+      { type: "phrase", value: "how it works end to end", weight: 4 },
+    ],
+    examples: ["how is Blindfold architected?", "explain the system design", "what are the components?"],
+  },
+  {
+    intent: "three_secret_paths",
+    patterns: [
+      { type: "phrase", value: "three ways", weight: 6 },
+      { type: "phrase", value: "three paths", weight: 6 },
+      { type: "phrase", value: "proxy vs release", weight: 7 },
+      { type: "phrase", value: "release vs proxy", weight: 7 },
+      { type: "phrase", value: "secret paths", weight: 6 },
+      { type: "phrase", value: "release broker", weight: 4 },
+    ],
+    examples: ["what are the three secret paths?", "proxy vs release?"],
+  },
Evidence
phrase patterns are substring matched, so a message like "components" matches the new
system_architecture pattern and yields patternScore=2. With the new KB entry confidence (0.97)
and the current confidence formula, that clamps to 1.0 (misleadingly high) even for such a
low-signal input; similarly, "three ways" yields patternScore=6 and also clamps to 1.0.

packages/chatbot/src/intents.ts[714-738]
packages/chatbot/src/classifier.ts[76-93]
packages/chatbot/src/engine.ts[99-104]
packages/chatbot/data/knowledge.json[20128-20161]
packages/chatbot/data/knowledge.json[20163-20188]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
New intent patterns for `system_architecture` and `three_secret_paths` include extremely generic phrases (e.g., `components`, `three ways`). Because phrase matching is substring-based and the engine’s confidence formula scales directly with raw pattern weight, these generic matches can produce **confidence=1.0** and route to the wrong intent.

### Issue Context
- `phrase` patterns match via `text.includes(...)`.
- Classification `score` is the sum of matched pattern weights.
- Engine confidence is `min(1, patternScore*0.5 + kbConfidence*0.4 + audienceBonus)`; with KB confidence ~0.96–0.97, even a single low-signal match can clamp to 1.

### Fix Focus Areas
- packages/chatbot/src/intents.ts[714-739]

### Suggested fix
- Remove or replace overly generic patterns:
 - Drop `{ type: "phrase", value: "components", ... }`.
 - Drop `{ type: "phrase", value: "three ways", ... }`.
- Prefer more specific phrases/regex that encode Blindfold context, e.g.:
 - `regex: "\\b(blindfold|tdx|enclave)\\b.*\\b(architecture|system design|components)\\b"`
 - `regex: "\\bthree\\b.*\\b(secret paths|sealed secret|proxy vs release|forward vs release)\\b"`
- If you want to keep a “components” trigger, make it contextual (e.g., `"blindfold components"`) and/or reduce weight so it can’t overwhelm unrelated intents.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Informational

2. KB deep-link URL mismatch 🐞 Bug ≡ Correctness
Description
The new kb-three-secret-paths entry’s link label includes the #4--the-three-secret-paths
fragment, but the URL omits it, so the rendered Sources link won’t navigate to the intended section.
Code

packages/chatbot/data/knowledge.json[R20176-20181]

+      "links": [
+        {
+          "label": "system_design.md#4--the-three-secret-paths",
+          "url": "system_design.md",
+          "type": "code"
+        }
Evidence
The KB entry’s link object has a fragment only in label, while responder.ts renders markdown
links using link.url, so the destination will be system_design.md without the section anchor.

packages/chatbot/data/knowledge.json[20176-20181]
packages/chatbot/src/responder.ts[72-79]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
A KB entry link label suggests a deep link (includes a `#...` fragment) but the actual `url` target is missing that fragment. The responder renders links using `link.url`, so users will not land on the intended section.

### Issue Context
In `kb-three-secret-paths`, the link object is:
- label: `system_design.md#4--the-three-secret-paths`
- url: `system_design.md`

### Fix Focus Areas
- packages/chatbot/data/knowledge.json[20176-20181]

### Suggested fix
Update the URL to include the anchor:
- `"url": "system_design.md#4--the-three-secret-paths"`
(Confirm the exact heading slug in `system_design.md` if GitHub’s generated anchor differs.)

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

Comment on lines +714 to +739
{
intent: "system_architecture",
patterns: [
{ type: "phrase", value: "system design", weight: 6 },
{ type: "phrase", value: "architect", weight: 5 },
{ type: "phrase", value: "design of", weight: 3 },
{ type: "phrase", value: "how is it built", weight: 4 },
{ type: "phrase", value: "how is blindfold built", weight: 5 },
{ type: "phrase", value: "how does the whole system", weight: 5 },
{ type: "phrase", value: "components", weight: 2 },
{ type: "phrase", value: "how it works end to end", weight: 4 },
],
examples: ["how is Blindfold architected?", "explain the system design", "what are the components?"],
},
{
intent: "three_secret_paths",
patterns: [
{ type: "phrase", value: "three ways", weight: 6 },
{ type: "phrase", value: "three paths", weight: 6 },
{ type: "phrase", value: "proxy vs release", weight: 7 },
{ type: "phrase", value: "release vs proxy", weight: 7 },
{ type: "phrase", value: "secret paths", weight: 6 },
{ type: "phrase", value: "release broker", weight: 4 },
],
examples: ["what are the three secret paths?", "proxy vs release?"],
},

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

1. Overconfident generic intents 🐞 Bug ≡ Correctness

The new intent patterns include very generic phrases (e.g., "components", "three ways") that are
matched via substring and can yield confidence=1.0 with only a single hit, causing incorrect intent
routing and overly confident answers for minimally-related queries.
Agent Prompt
### Issue description
New intent patterns for `system_architecture` and `three_secret_paths` include extremely generic phrases (e.g., `components`, `three ways`). Because phrase matching is substring-based and the engine’s confidence formula scales directly with raw pattern weight, these generic matches can produce **confidence=1.0** and route to the wrong intent.

### Issue Context
- `phrase` patterns match via `text.includes(...)`.
- Classification `score` is the sum of matched pattern weights.
- Engine confidence is `min(1, patternScore*0.5 + kbConfidence*0.4 + audienceBonus)`; with KB confidence ~0.96–0.97, even a single low-signal match can clamp to 1.

### Fix Focus Areas
- packages/chatbot/src/intents.ts[714-739]

### Suggested fix
- Remove or replace overly generic patterns:
  - Drop `{ type: "phrase", value: "components", ... }`.
  - Drop `{ type: "phrase", value: "three ways", ... }`.
- Prefer more specific phrases/regex that encode Blindfold context, e.g.:
  - `regex: "\\b(blindfold|tdx|enclave)\\b.*\\b(architecture|system design|components)\\b"`
  - `regex: "\\bthree\\b.*\\b(secret paths|sealed secret|proxy vs release|forward vs release)\\b"`
- If you want to keep a “components” trigger, make it contextual (e.g., `"blindfold components"`) and/or reduce weight so it can’t overwhelm unrelated intents.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +20176 to +20181
"links": [
{
"label": "system_design.md#4--the-three-secret-paths",
"url": "system_design.md",
"type": "code"
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Informational

2. Kb deep-link url mismatch 🐞 Bug ≡ Correctness

The new kb-three-secret-paths entry’s link label includes the #4--the-three-secret-paths
fragment, but the URL omits it, so the rendered Sources link won’t navigate to the intended section.
Agent Prompt
### Issue description
A KB entry link label suggests a deep link (includes a `#...` fragment) but the actual `url` target is missing that fragment. The responder renders links using `link.url`, so users will not land on the intended section.

### Issue Context
In `kb-three-secret-paths`, the link object is:
- label: `system_design.md#4--the-three-secret-paths`
- url: `system_design.md`

### Fix Focus Areas
- packages/chatbot/data/knowledge.json[20176-20181]

### Suggested fix
Update the URL to include the anchor:
- `"url": "system_design.md#4--the-three-secret-paths"`
(Confirm the exact heading slug in `system_design.md` if GitHub’s generated anchor differs.)

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

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