Aventuras/docs/development/network-requests.md
Tony Frazier f6a096b48f
Move the docs to decision records and check them on every push (#807)
This swaps CLAUDE.md and the hand-written docs index for a small
decision-record setup, and adds a script that checks the docs so they
stop drifting from the code.

## What changes

CLAUDE.md is gone. AGENTS.md replaces it as the one instruction file for
people and coding agents alike. It has the commands, the rules for every
change, the area-doc table, and how to record a decision. (Claude Code
only reads AGENTS.md when there's no CLAUDE.md, so it's deleted rather
than kept around as an import.)

If you use Claude Code, check one thing. It only reads AGENTS.md on
version 2.1.277 or later, and only when there's no `CLAUDE.md`,
`.claude/CLAUDE.md` or `CLAUDE.local.md` in the repo or any directory
above it. If you keep one of those, set **Project instructions** to
`claude-md-and-agents-md` in `/config` to load both. Your
`~/.claude/CLAUDE.md` doesn't count, so it's fine.

Decisions now live in `docs/decisions/`, one file each, named
`YYYY-MM-DD-slug.md`. There's one so far, the record system itself. It
sets the bar for when a choice gets an ADR at all: intent the code can't
express that spans more than one site or won't fit in a short comment.
Anything smaller stays a comment, and refining a decision amends its ADR
instead of adding a new one.

Only tagged decisions are listed in `docs/README.md`, so the index grows
with the decisions that span areas, not with every local choice. The
code leads to the local ones, either through an `ADR(slug)` comment at a
single site or through `scope`, which lists the directories an ADR
governs. For each scoped directory, `npm run docs:gen` writes the ADRs'
summaries into a generated block in that directory's `AGENTS.md`, which
Claude Code loads when it reads a file there or below. Any hand-written
text in that file is left alone. `docs/README.md`, the cross-cutting
block in AGENTS.md and the scoped blocks are all generated, so don't
edit those by hand.

Once an ADR merges, its summary is the ruling and can't change. The rest
of the record can still be refined while the summary holds. Changing the
ruling means superseding the ADR.

Raw material (logs, benchmarks, probe output) goes in `docs/evidence/`,
and an ADR has to link it. A new `.ignore` lists the folder so a keyword
search over the whole repository skips it, while a search aimed at the
folder still finds it. Agents reach evidence through the ADR's link. Two
evidence docs record how that was tested: which tools load a nested
AGENTS.md (only the Read tool does), and why no hook or instruction file
guards the folder.

`npm run docs:check` (`scripts/docs-check.ts`) checks:

- the decision files and the generated output
- `ADR(slug)` comments and scopes
- `docs/` paths named in source
- relative links in Markdown
- that evidence files are linked from a decision

It also fails if a merged ADR's summary changed or its slug disappeared,
comparing against the merge-base with `origin/master`. `--base <ref>`
picks another ref, and a ref git can't resolve is an error. The default
`origin/master` only warns when it's missing, so a clone without that
remote can still run the check. (`master` has no decisions yet, so
there's nothing to compare until this merges.) An active ADR with no
tag, no scope and no anchor draws a warning, since nothing would lead a
reader to it. Cross-cutting ADRs are exempt because AGENTS.md lists
them.

`npm run docs:gen` writes nothing while an ADR or the tag list is
invalid. Otherwise a broken record would quietly drop out of the index
and the AGENTS.md blocks.

The check runs in pre-push on every push, and with `--strict` in a new
Docs check workflow on PRs to master. That workflow fetches the full
history so the merge-base exists.

The rules that were in CLAUDE.md now have their own files under
`docs/development/`, indexed by `docs/development/README.md`.
`release.md` and `platform-support.md` are each split into the rules and
a separate evidence file. `docs/ARCHITECTURE.md` is a starting map of
the code, and `docs/architecture/network-transport.md` is new.

Every doc under `docs/architecture/` and `docs/development/` was also
checked against the current code and corrected where it had drifted.

## Smaller changes

- Markdown under `docs/` is forced to LF (`.gitattributes` and
`docs/.editorconfig`).
- Git no longer ignores AGENTS.md or `docs/evidence/`, and the ignores
for the old root-level doc files now match only at the repo root.
- tsconfig and vitest now pick up TypeScript under `scripts/`.
- The README points contributors at AGENTS.md and drops the link to the
iOS build doc.

## Needs a follow-up

`.github/CODEOWNERS` puts `docs/decisions/` under a placeholder team
(`@AventurasTeam/TODO-owning-team`). GitHub ignores an owner it can't
resolve, so it does nothing until someone fills in the real team.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01EzTd9Y26s2eHcacyqFi1QK


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Documentation**
* Added repository guidance for development rules, required checks, and
decision records; updated the README to direct contributors to the
relevant guides.
* Added checks and generated documentation for decision records, links,
evidence references, and summaries.
* Added ownership guidance for decision records and standardized
Markdown line endings in the documentation directory.
* Replaced the previous repository guide with the new contributor
guidance.

* **Chores**
* Documentation checks now run on pull requests and before pushing
changes.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-02 16:24:21 -05:00

3.3 KiB

Network requests

Rule. Remote HTTP goes through Tauri's HTTP plugin, by way of one of the helpers below — never the WebView's fetch. The WebView's fetch works in dev against an https host, then fails in an Android release build or on iOS for a http:// server, and wherever the server sends no CORS headers. The reasoning and the data are in network-transport.md.

Which helper

Job Use
An AI SDK provider createTimeoutFetch (services/ai/sdk/providers/fetch.ts); registry.ts injects it
An SDK image model createSdkFetch (sdkFetch.ts); a poll, createPollSdkFetch, which logs it as one entry
Image model discovery or a GET to the configured server imageGetFetch (services/ai/image/providers/fetchAdapter.ts)
A URL from a card or anywhere else the user did not type fetchPublicImageBase64, which also checks each redirect hop against the public-host rule
Card discovery, Fandom and other plain GETs corsFetch (services/discovery/utils.ts); it logs nothing unless passed debug
Any other request of the app's own loggedFetch (services/http/), which the helpers above are built on (corsFetch only with debug)

httpFetch (services/http/httpFetch.ts) is the only way into the plugin, and an ESLint rule rejects any other import of its fetch: it drops the webview Origin that local servers reject. Call it directly only for a request that should not be logged, as updater.ts and the model-health ping do.

createTimeoutFetch buffers only a JSON success, to patch its usage; errors and streams go back to the SDK unread. Read every logged body with readLoggedBody, which never throws.

Aborts and timeouts

  • A timeout makes an abort an AbortError. loggedFetch given a timeoutMs wraps the request in a request guard, which maps a caller's abort to an AbortError and its own timeout to a RequestTimeoutError. Without one, the plugin rejects with a plain Error or a bare string, depending on timing, and a stream that is cut errors with a bare string (network-transport.md). There, check signal.aborted first; do not rely on error.name or the message.
  • The header timer stops at the headers; the idle timer bounds the body. A non-streaming completion sends its headers early and its body when generation finishes, so for it the idle timer is the whole generation's deadline: the LLM timeout setting.

Rust side

The app's own reqwest (LAN sync, desktop updater) uses the OS trust store and the ring provider installed in src-tauri/src/lib.rs. A new dependency or feature must not bring a second TLS provider: cargo tree -i aws-lc-rs must find no package.