Skip to content

Latest commit

 

History

History
350 lines (290 loc) · 18.7 KB

AGENTS.md

File metadata and controls

350 lines (290 loc) · 18.7 KB

AGENTS.md

Guidelines for agentic coding agents working in this repository.


Project Overview

Public repo for BayLeaf, a situated counterplatform for Generative AI serving the UC Santa Cruz campus community and operated by Adam Smith (Dept. of Computational Media). Publicly visible; never commit secrets, API keys, or credentials.

  • BayLeaf Chat — https://chat.bayleaf.dev — Open WebUI with curated OpenRouter ZDR models, both proprietary and open-weight, invite-code-gated groups, web search/browsing tools, and rate limiting.
  • BayLeaf API — https://api.bayleaf.dev — plaintext OpenRouter inference restricted to verifiably open-weight models, plus Sealed confidential inference through Tinfoil. It provides keyless on-campus access, key-based off-campus access, web search/fetch, and sandboxed code execution. Source: api/ in this repo. It also serves a keyless, read-only HF artifact gateway at https://api.bayleaf.dev/hf/: approved Hugging Face model files mirrored into R2 (issue #121, see api/HF-GATEWAY.md).
  • BayLeaf Probe: https://probe.bayleaf.dev, a non-public, HTTP-Basic-authenticated Cloudflare Worker powering UptimeRobot synthetic monitoring. Its deployed layers test browser-based Chat, OWUI HTTP inference, direct OpenRouter inference, and keyed BayLeaf API inference. Source: chat/probe/. The public monitoring/status surface is https://status.bayleaf.dev, served by UptimeRobot.

A self-service course-AI service (BayLeaf Courses) was prototyped and then retired (GitHub issues #4 and #5); the Spring 2026 course need was met instead by the Brace3 OWUI configuration under chat/. It may be rebuilt with richer context in the future.

All active LLM inference uses zero-data-retention (ZDR) providers. Chat and the API's plaintext lane use OpenRouter; API Sealed uses Tinfoil.

Project Frame

BayLeaf describes itself as a situated counterplatform for Generative AI at UC Santa Cruz. A counterplatform is not a rival seeking scale or a claim that building infrastructure supersedes critique, organizing, policy, or refusal. It is one situated mode of response: operating a platform makes alternative technical and institutional terms concrete, usable, scrutinizable, and revisable.

Naming: BayLeaf is the proper name; "situated counterplatform" describes what it is. Do not use "BayLeaf AI Playground" or substitute "Counterplatform" as a product-name suffix. Preserve "playground" only inside immutable external identifiers or genuine historical quotations.

Treat AI as consequential but normal technology, neither autonomous nor inevitable. Discuss risk at the level of situated use cases and sociotechnical relations, not models or safeguards alone. Technical controls are interventions, not proof that BayLeaf is safe by definition.

Data posture: ZDR everywhere, ZOA where possible

Two distinct properties, often conflated:

  • ZDR (zero data retention) is a retention property: data is processed transiently and not persisted. It is the floor for the whole platform. Every inference path routes only to provider endpoints that contract not to retain prompts or completions (and never train on them); they keep only request metadata. BayLeaf applies ZDR to itself as well: the API proxy stores no prompt or completion content.
  • ZOA (zero operator access), as articulated in the AWS Mantle design, is a stronger access property: there is no technical means for an operator to read user content even while it transits, enforced architecturally (no interactive shells, signed/attested code, encrypted-in-use). ZOA implies ZDR, but ZDR does not imply ZOA: a ZDR system can still let an operator tail a log or deploy a logging build.

Stance: pursue ZOA where practical, ZDR everywhere as the baseline.

  • BayLeaf API is the ZOA target. It retains no prompt or completion content, disables Workers observability, and does no content caching, so an operator has no standing access to prompts or completions: only request metadata (model, token counts, timestamps) is observable. Positive and definite-negative plaintext model-eligibility verdicts, never request content, are cached in MODEL_STATUS KV for 24 hours. Unknown verdicts fail closed with HTTP 403 and are not cached. This is a strong ZOA posture, not a hardware-attested ZOA guarantee like Mantle, because an operator with deploy rights could ship a revision that logs request bodies; there is no attestation/signed-deploy barrier preventing it. Claim the posture honestly; do not overclaim full ZOA. Any change that begins storing or logging request content breaks this posture and must be treated as a material change. API Sealed is stronger: clients encrypt the model and request body to an attested Tinfoil enclave, so BayLeaf carries ciphertext it cannot decrypt.
  • BayLeaf Chat cannot be ZOA: it deliberately stores chat history so users can carry conversations across devices. The administrator can read that database. Chat is ZDR at the inference layer only; be explicit that the ZDR boundary does not cover stored conversation history.

Repository Structure

bayleaf/
├── api/                # BayLeaf API — Cloudflare Worker (has its own AGENTS.md)
│   ├── src/
│   ├── migrations/
│   ├── wrangler.jsonc
│   └── package.json
├── chat/               # BayLeaf Chat — Open WebUI config & backup (has its own AGENTS.md)
│   ├── DESIGN.md       # Full architecture, env vars, recovery procedure
│   ├── image/          # Production image: pinned OWUI + guarded startup patch
│   ├── models/         # Workspace model definitions (JSON + avatars)
│   ├── tools/          # Custom toolkit source code
│   ├── functions/      # Filter & action source code
│   └── probe/          # Private layered monitoring Worker (has its own AGENTS.md)
├── landing/              # GitHub Pages site → https://bayleaf.dev
│   ├── CNAME
│   ├── index.html        # Comprehensive landing page (the only bayleaf.dev page)
│   ├── style.css         # Stylesheet (carries a WCAG contrast invariant)
│   ├── llms.txt          # Agent-facing gloss of surfaces; defers to api.bayleaf.dev/llms.txt
│   └── images/           # og-card.png + the script that generates it
├── inbox/                # BayLeaf Inboxes Worker (#97; authenticated campus owners)
├── rooms/                # BayLeaf Rooms Worker (#159; shared state for static apps)
├── sandbox/              # Public BayLeaf Sandboxes home → https://sandbox.bayleaf.dev
├── telemetry/            # Live first-party collector/D1; private data, public status (#112)
├── politics/             # Dependency audit, VPATs, position papers
├── scripts/              # GitHub Pages artifact builder
├── training/             # Work-in-progress React site for training users in effective GenAI usage
├── DIRECT-INTEGRATIONS.md # Trust boundaries for direct GWS/Canvas agent integrations
├── README.md
└── AGENTS.md             # This file

(DIRECT-INTEGRATIONS.md, GETTING-STARTED.md, USE-CASES.md, PRIVACY.md, and SUPPORT.md at the repo root appear before api/ alphabetically; see the top-level listing.)

landing/ is published via GitHub Pages at https://bayleaf.dev. It is the only hand-written HTML surface: a single comprehensive landing page. Companion user-facing documents (use cases, privacy notice, support channels) live as top-level markdown (USE-CASES.md, PRIVACY.md, SUPPORT.md) served by GitHub's rendered markdown, not as bayleaf.dev pages. The landing page links to them with absolute GitHub URLs; markdown files link to each other and to repo files with relative links. Treat "a new page on bayleaf.dev" as a high bar: prefer editing the markdown files and linking to them, and before adding any platform surface, consider whether GitHub-served markdown suffices.

api/ is a Cloudflare Worker deployed at https://api.bayleaf.dev. Read api/AGENTS.md before working on API code or infrastructure.

inbox/ is the separate bayleaf-inboxes Worker (issue #97): opaque email and webhook addresses on bayleaf-inboxes.dev, with its own D1 and R2, managed only through the API's INBOXES service binding. It intentionally stores received content, so it is outside the API's ZDR/ZOA posture. Deployed for operator-only email/webhook qualification, now available to authenticated campus owners; optional creation-only DKIM domain allowlists are enabled for new email inboxes. Read inbox/AGENTS.md and inbox/DESIGN.md before working on it.

rooms/ is the separate bayleaf-rooms Worker (issue #159): durable shared logs (JSON or Yjs) with live WebSocket relay for static apps, served to participants on bayleaf-rooms.dev through capability links, with one Durable Object per room and its own D1 owner index. Owners manage rooms only through the API's ROOMS service binding (/rooms on api.bayleaf.dev). It intentionally stores participant content, so it is outside the API's ZDR/ZOA posture. BayLeaf relays, it does not arbitrate. Read rooms/AGENTS.md and rooms/DESIGN.md before working on it.

Place scripts and analysis machinery for a specific service inside that service's directory (for example, api/scripts/ or chat/analysis/), not at the repository root.

chat/ is an Open WebUI instance on DigitalOcean App Platform at https://chat.bayleaf.dev. Read chat/AGENTS.md before working on Chat configuration, models, tools, functions, or user/group management.

chat/probe/ is a separate Cloudflare Worker, not part of the OWUI deployment or BayLeaf API. Read chat/probe/AGENTS.md before working on monitoring; it explains the probe contracts, latency metrics, current measurement snapshot, cleanup requirements, and credential expiry. Keep all probe layers in this single Worker.

UptimeRobot calls the private probe endpoints as ordinary authenticated HTTP monitors. Both GET and HEAD wait for completed work; the resulting status and response time power availability monitoring and https://status.bayleaf.dev. UptimeRobot owns history, public status presentation, and alerts; the Worker returns content-free diagnostics and creates no metrics store. Browser probes temporarily persist only marked synthetic chats and must verify their deletion. Detailed phase timings are available from authenticated probe responses, not assumed to be archived by UptimeRobot. Verify monitor configuration and alert delivery separately from endpoint health. The deployed probes do not test CILogon. A Sealed backend probe at /api/sealed is deployed and production-qualified (2026-10-07), with public monitoring confirmed and alert delivery unverified; see chat/probe/README.md. The keyed inference layer does not test Campus Pass or the API's non-inference facets. A separate passive /api/sandbox existence probe is deployed/qualified (2026-10-27 Pacific), included on BayLeaf Status, and uses hourly HEAD polling without waking compute; it does not test runtime usability. The browser's worst-case execution currently exceeds UptimeRobot's maximum timeout; see the probe guide before enabling alerts.

Repo-local agent skills (experimental)

.agents/skills/ holds repo-specific skills, currently the bayleaf-ops-router operations playbooks (issue #65). These are experimental and unproven: most have never guided a real run. Expect to deviate from them, and treat every deviation as data — after finishing a workflow, record what differed in the playbook's refinement log and fix any step that reality contradicted (the router's own instructions say the same). They will earn their keep only through practice, not by being followed faithfully.


Build / Lint / Test

The landing site source (landing/) is one hand-written static HTML page with a stylesheet. GitHub Actions runs scripts/build_pages.py to copy that source into a Pages artifact and replace the landing page's recent-posts fallback with five entries from the public BayLeaf Blog RSS feed. The deployed site still has no JavaScript dependency for page content or controls. An optional self-hosted arrival collector performs no DOM updates. For the API (api/), see api/AGENTS.md for build and deploy commands.

Five things in or deployed from landing/ are generated rather than hand-written:

  • landing/images/og-card.png, the Open Graph share card. Regenerate with ./landing/images/make-og-card.py after changing the tagline or the palette. Its source art is chat/models/basic/profile.png, the BayLeaf logo.
  • landing/arrival.js, the self-hosted optional browser arrival bundle. Regenerate with node telemetry/browser/build.mjs; telemetry/browser/config.json owns its explicit activation state (currently true). Normal builds preserve that configured state. Do not hand-edit the bundle or enable collection implicitly.
  • The empirical claims in politics/VPAT-pages.md. Any change to landing/index.html or landing/style.css can invalidate a measured contrast ratio, a reflow result, or a structural claim. GitHub-served markdown files (PRIVACY.md, etc.) render in GitHub's UI and are outside that ACR's scope.
  • The recent-post rows in deployed index.html. They are generated only in the Pages artifact by scripts/build_pages.py; do not commit them to the source template. The scheduled and manually dispatchable Pages workflow refreshes them.
  • The exact-model FAQ answer in deployed index.html. The same builder reads chat/models/basic/model.json (base_model_id) and api/wrangler.jsonc (RECOMMENDED_MODEL). OpenRouter selections link to upstream model pages; other identifiers link to the repository configuration. Keep the source fallback and current-models markers, not generated model names. Pages refreshes daily at 08:17 UTC, on pushes to main, and on manual dispatch.

Local preview of the source fallback: Use the VS Code Live Server extension (right-click landing/index.html → Open with Live Server), which serves on http://localhost:5500 by default. To preview the generated site:

python3 scripts/build_pages.py --output /tmp/bayleaf-pages
python3 -m http.server 8000 --directory /tmp/bayleaf-pages

Security & Privacy

First-party telemetry

https://telemetry.bayleaf.dev is the live Worker/D1 collector, separate from the API and probe Workers. Its root is a public configuration-status page, not a data dashboard. Reads require a dedicated operator capability; service writers have separate source-scoped credentials. Read telemetry/AGENTS.md before changing it.

The approved slice comprises public arrivals on landing/API/Sandboxes, signed-out Chat root, Proxies apex entry/recovery and Inboxes apex entry (never tenant origins or authenticated diagnostics), five native OWUI aggregate metrics, existing synthetic probe summaries, and aggregate deletion-job reports. Fixed 15-minute Inboxes receipt/lifecycle/ cleanup metrics are also approved, without addresses, inbox/account identifiers, paths, credentials or content. Fixed 15-minute Rooms aggregates (6 names, 30 series, policy 5) are approved likewise, without room/credential/owner identifiers, labels, content or presence state, and are never published. All have a 90-day active maximum; provider recovery history and derived-artifact expiry are documented in PRIVACY.md. Browser records contain no visitor identifiers or retained IPs: only a coarse campus/other/unknown network category is derived transiently at the collector. Deletion hooks are deployed; ordinary scheduled-report verification remains pending. See telemetry/qualification/rollout.md for evidence and remaining acceptance work.

  • No secrets in the repo. No API keys, tokens, passwords, or .env files.
  • Any code calling LLM APIs must use an approved ZDR path. Plaintext inference uses OpenRouter; Sealed inference uses Tinfoil and must remain encrypted from BayLeaf. Note the applicable boundary in comments.
  • Invite codes, filter names, and internal operational details must not appear in committed files.

Agent Conduct

This repo backs a live service used by the entire UC Santa Cruz campus community. Do not perform destructive or publishing actions unless explicitly asked. This includes — but is not limited to — committing, pushing, force-pushing, deleting branches, or modifying GitHub settings. Always show the user a diff or summary and wait for approval before touching git history or remote state.


Git Workflow

Deploy first, commit later. All services in this repo can be deployed to production without committing. Use this to let the developer feel out changes in prod before recording them in git. The Pages workflow deploys committed source changes on push and refreshes public-data snapshots on a schedule or manual dispatch; use the generated local preview above to inspect source changes before committing.

Do not commit or push unless explicitly asked. Deploying to a live service is non-destructive and reversible; pushing to main is immediate and public. These are different levels of commitment.

Clean commit story over chronological accuracy. When a session produces multiple small, related changes (e.g. a feature + copy tweaks + style fixes), prefer squashing them into a single coherent commit rather than recording each micro-step. The git log should read like an intentional changelog, not a transcript of the development session.


Review Bots

Greptile and CodeRabbit review every PR, including incremental pushes (tuning: issue #136, .coderabbit.yaml).

  • Fix plausible findings; don't change code just to please a bot. The PR's author decides when to stop fix rounds, and cosmetic suggestions alone never justify one. Docs that misstate permissions, consent, behavior, or evidence are not cosmetic.
  • Greptile's review is sufficient to merge; CodeRabbit's re-review does not gate it. Neither licenses ignoring a known substantive finding.
  • Before merging, read both bots' summaries, threads, and outside-diff findings, not just those since the last push.
  • After merging, check for late findings. Fix, dismiss with a reason, or propose a follow-up (ask before opening it). If review is still running, say so in the handoff.

Commit Style

add:    new content or feature
update: change to existing content or feature
fix:    bug fix
docs:   documentation only
chore:  tooling, deps, CI

Concise, imperative mood: add screenshot gallery to about page ✓


BayLeaf is a convivial, sufficiency-capped degrowth artifact funded by a gift economy and animated, in places, by an innovation-accelerationist pulse it hasn't fully reconciled.