Skip to content

docs: add ReadTheDocs documentation site with MkDocs Material#2

Merged
dortort merged 13 commits into
mainfrom
docs/readthedocs-setup
Feb 25, 2026
Merged

docs: add ReadTheDocs documentation site with MkDocs Material#2
dortort merged 13 commits into
mainfrom
docs/readthedocs-setup

Conversation

@dortort
Copy link
Copy Markdown
Owner

@dortort dortort commented Feb 17, 2026

Summary

  • Set up a complete ReadTheDocs-compatible documentation site using MkDocs with Material theme
  • 30 documentation pages covering every feature of ai-tool-guard with code examples
  • .readthedocs.yaml for automated RTD deployment (Python 3.12, ubuntu-24.04)
  • CI validation via mkdocs build --strict on every PR

Documentation structure

Section Pages Content
Home 1 Project overview, feature grid, architecture diagram
Getting Started 3 Installation, quick start, core concepts
Guides 14 One deep-dive per feature (policy engine, approval workflows, argument validation, injection detection, output filtering, rate limiting, OTel, MCP drift, simulation, conversation-aware policies, error handling, decision records, preset policies, external backends)
API Reference 8 Complete reference for all 6 subpath exports + types catalog
Examples 4 Next.js integration, chatbot safety, multi-tenant policies, audit logging

Additional changes

  • Added docs:build and docs:serve scripts to package.json
  • Added docs job to CI workflow (.github/workflows/ci.yml)
  • Updated .gitignore to exclude site/ build output

Test plan

  • mkdocs build --strict passes with zero warnings
  • All 30 pages have substantive content (no stubs/placeholders)
  • Every public export from src/index.ts is documented in API reference
  • mkdocs serve renders all pages with working navigation
  • ReadTheDocs import and build succeeds after merge

Note

Low Risk
Documentation- and CI-only changes; no runtime/library code or security-sensitive logic is modified.

Overview
Introduces a MkDocs Material documentation site (new mkdocs.yml, docs/ content, and docs/requirements.txt) and adds Read the Docs deployment via .readthedocs.yaml.

Updates CI to run a dedicated docs build (mkdocs build --strict) and ignores the generated site/ output; README.md formatting is adjusted to align with the new docs and improve table/diagram rendering.

Written by Cursor Bugbot for commit 4e32eb6. This will update automatically on new commits. Configure here.

…ocs config

Set up documentation site infrastructure:
- mkdocs.yml with Material theme, code highlighting, dark mode, tabs
- .readthedocs.yaml for RTD deployment (Python 3.12, ubuntu-24.04)
- docs/requirements.txt pinning mkdocs-material 9.x
- 30 stub pages matching full nav structure
- Updated .gitignore to exclude site/ build output
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 93ef52d2f8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/guides/injection-detection.md Outdated
The injection check runs first in the evaluation pipeline. It scores the tool arguments for adversarial patterns and, depending on configuration, either blocks the call outright, downgrades it to require human approval, or logs it and proceeds. The check is optional and opt-in: configure `injectionDetection` on `GuardOptions` to enable it.

```typescript
import { createGuard } from "ai-tool-guard";
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Use the actual public API names in guide snippets

The new guides repeatedly import createGuard/guardTool from ai-tool-guard, but those symbols are not exported by the package (the root API is createToolGuard, and tool wrapping is done via guard.guardTool(...)). As written, users who copy these examples will hit immediate TypeScript/runtime import errors, so the docs are not executable in their current form; I confirmed the mismatch in src/index.ts and it appears in multiple new guide files (argument validation, injection detection, output filtering, and rate limiting).

Useful? React with 👍 / 👎.

…formatting

Remove internal requirement column from features table, center text in
architecture diagram box, fix PolicyBackend box width, and align inline
comments in error handling example.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@chatgpt-codex-connector
Copy link
Copy Markdown

💡 Codex Review

const safeTool = guardTool(myTool, {

P2 Badge Call guard.guardTool with a tool name in concepts snippet

This example uses guardTool(myTool, {...}), but the public API requires ToolGuard.guardTool(name, tool, config?) (src/guard.ts), so copying this snippet will fail type-checking and won’t run even after switching to instance usage. The missing name argument also means the guard cannot build the required toolName context for policy evaluation.


console.warn(`Rate limited. Retry after ${err.retryAfterMs}ms`);

P2 Badge Remove retryAfterMs access from ToolGuardError example

The catch block reads err.retryAfterMs, but ToolGuardError only exposes code, toolName, and optional decision (src/guard.ts), so this sample yields a TypeScript error (or undefined at runtime). retryAfterMs is returned by RateLimiter.acquire, not propagated onto thrown guard errors.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

dortort and others added 2 commits February 24, 2026 15:49
…ToolGuard)

Address PR review: guide code examples used non-existent createGuard and
standalone guardTool imports. Replace with the actual public API names
createToolGuard and guard.guardTool(name, tool, config) across all
affected guides (argument validation, injection detection, output
filtering, rate limiting).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…usage

Add missing tool name arg to guard.guardTool() in concepts guide.
Replace err.retryAfterMs (not a ToolGuardError property) with
err.message in rate-limiting error handling example.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: afb62e1105

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/getting-started/concepts.md Outdated

3. **Policy evaluation** — The guard evaluates all matching rules (built-in defaults, custom rules, and responses from any configured external backend) and resolves a final verdict using escalation semantics.

4. **Approval flow** — If the resolved verdict is `require-approval`, execution pauses and the `onApprovalRequired` callback is invoked. The callback receives the full decision context and must return `"approved"` or `"denied"` to continue or abort.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Describe the real approval callback return type

This states that onApprovalRequired must return the strings "approved"/"denied", but the runtime expects an ApprovalResolution object with an approved boolean (and optional patchedArgs). If users follow this text and return a string, ApprovalManager.resolveToken sees resolution.approved as falsy and denies every approval-gated tool call, so all require-approval flows fail.

Useful? React with 👍 / 👎.

Comment thread docs/getting-started/concepts.md Outdated
```typescript
const guard = createToolGuard({
// GuardOptions — applies to every tool
rules: [defaultPolicy()],
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Pass defaultPolicy() directly in rules

The example wraps defaultPolicy() in an extra array, but defaultPolicy() already returns PolicyRule[]. Copying this produces PolicyRule[][], which either fails type-checking or reaches runtime where rule iteration expects rule.toolPatterns on each element and crashes when the element is an array.

Useful? React with 👍 / 👎.

Comment thread docs/getting-started/concepts.md Outdated
Comment on lines +221 to +223
argGuards: {
email: { pii: true },
},
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Configure argGuards as an array in the example

This snippet models argGuards as an object map, but ToolGuardConfig.argGuards is an ArgGuard[]. In plain JS, this object has no length, so the guard pipeline condition config.argGuards.length > 0 is false and argument validation is skipped entirely, silently disabling the protections this section is trying to teach.

Useful? React with 👍 / 👎.

… type in concepts

- Describe onApprovalRequired as returning ApprovalResolution object
  (not string literals)
- Remove extra array wrapper around defaultPolicy() which already
  returns PolicyRule[]
- Change argGuards from object map to ArgGuard[] array using piiGuard()

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@dortort dortort merged commit 1e3a5d0 into main Feb 25, 2026
4 checks passed
@dortort dortort deleted the docs/readthedocs-setup branch February 25, 2026 04:27
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