Purpose: This document provides essential context for anyone (human or agent) working on the rlinks project.
rlinks is a URL shortener and redirect service running on Cloudflare Workers, designed for personal/small-team use with strong operational and security guarantees.
Core Value Proposition:
- 🔒 Secure: Single-writer discipline, immutable audit trail
- ⚡ Fast: Edge-optimized, sub-10ms redirects
- 🛠️ Operator-friendly: CLI-first, GitOps-compatible
- 📊 Observable: Every hit logged, full audit capability
Invariant: Only the CLI (rlinks) may write or modify redirect records in Cloudflare KV.
Why: Prevents data corruption, enables strong consistency guarantees, simplifies audit trails.
Implication: Never use Wrangler, Terraform, or the Cloudflare dashboard to modify redirect data directly.
Invariant: All redirect data is typed, validated, and versioned.
Why: Enables safe evolution, prevents malformed data at the edge.
Implication: Changes to redirect behavior start with schema updates in rlinks-core, followed by CLI and Worker compatibility.
Invariant: Schema versions only increase; old versions must be readable by new code.
Why: Allows rolling updates without downtime.
Implication: New fields must be optional or have migrations; deletions require explicit version bumps and compatibility windows.
Invariant: Every redirect hit is logged; every mutation is audited.
Why: Enables post-incident analysis, usage analytics, and security forensics.
Implication: Hit logs are append-only in KV; the Worker never skips logging (even on errors).
Invariant: Redirects resolve in O(1) time with a single KV lookup, targeting <10ms p99.
Why: Core user experience depends on speed; complexity belongs in CLI/batch jobs.
Implication: No heavy computation, no network calls (except KV), no analytics aggregation in the hot path.
- Defines
RedirectRecordschema and validation rules - Shared by CLI and Worker
- Source of truth for data structure
- Command-line tool for redirect management
- Only component authorized to write to KV
- Validates all inputs before mutation
- Edge redirect service
- Read-only KV access (except hit logs)
- Handles HTTP requests at
rmax.to/*
Normal Operations:
- Operator runs
rlinks create <code> <url> - CLI validates and writes to KV
- Worker picks up changes immediately (no deploy)
Emergency Scenarios:
- Use
rlinks disable <code>to stop a redirect - Never delete records; disable them (preserves audit trail)
- See
docs/failure-modes.mdfor incident response
- Read first: Check
AGENTS.md,docs/GUIDELINES.md,docs/DEVELOPMENT.md - Schema changes: Update
rlinks-core, then tests, then docs - Test everything:
cargo test --workspace,cargo clippy,cargo fmt - Document decisions: Add to
docs/DECISIONS/if architectural - Never commit secrets: Use
.env.exampleand rotate if exposed
Threat Model: Documented in docs/security.md
Key Threats:
- Unauthorized redirect modification → Mitigated by single-writer + API token rotation
- Redirect hijacking → Mitigated by validation rules (no loops, HTTPS-only)
- Hit log manipulation → Mitigated by append-only + KV ACLs
- Token exposure → Mitigated by secret rotation + audit logs
Incident Response: Follow docs/security.md procedures immediately.
- ✅ Core implementation complete (PoC validated)
- 🔄 Finalizing specification (
docs/SPEC.md) - ⏳ Building integration test suite
- ⏳ Preparing for alpha deployment
See PROGRESS.md and PHASE_LEDGER.md for detailed status.
If you're an AI agent:
- Read
AGENTS.mdfor operational rules - Check
NEXT_STEPS.mdbefore starting work - Follow
.agent/WORKFLOW.mdfor process discipline - Use the todo list to track your work
- Never commit unless explicitly asked
- Always run tests after changes
If you're configuring an agent:
- Point it to this file first for context
- Ensure it reads linked docs before acting
- Verify it follows single-writer and schema-first rules
- Monitor for policy violations (direct KV edits, secret exposure)
- Architecture:
docs/architecture.md - Schema:
docs/schema.md - Spec:
docs/SPEC.md - Security:
docs/security.md - Operations:
docs/operations.md - Development:
docs/DEVELOPMENT.md - Agent Rules:
AGENTS.md - Current Plan:
.agent/PLAN.md
Last Updated: 2026-01-28
Maintainer: See created_by metadata in redirect records (e.g., max@rmax.ai)