Rules and code
What every agent reads before it works, and what code enforces: the Rulebook, the policy, the catalog of allowed changes, the coding guidelines, the code map and the project profile.
🔒 Read-only copy of main at 4c3ef2b7, refreshed by every Live Patrol (27 Oct 12:55 UTC). These files change only through a merge request; agents can never change the Rulebook, the policy or the code map.
Code map: vallum-link-shortener
Generated by code from the repository and vallum/project.yaml (python -m vallum.codemap). Never edit by hand; it is refreshed after every release.
A link shortener for small businesses: create short links, redirect visitors, see link details.
Layout
- Language: python (fastapi)
- Source:
app; tests:tests - A feature lives in
app/features/{module}.py, its tests intests/test_{module}.py, its Feature Card inpromises/features/{issue}-{feature}.yaml - Entry points:
app/main.py - Never edited by a feature:
app/main.py,app/store.py,app/security.py - Test command:
pytest; health check:/health
Features (from Feature Cards)
| Feature | Tier | Kind | Routes | Files | Flag | Promises |
|---|---|---|---|---|---|---|
| custom-alias | standard | new-endpoint | POST /api/aliases | app/features/custom_alias.pytests/test_custom_alias.py | custom_alias | behavior: alias-redirects, alias-taken-is-refused, alias-valid-chars-only, alias-url-must-be-http, alias-url-length-limit, alias-create-needs-key, alias-response-shape; reliability: alias-create-reliable; security: alias-sec-needs-key, alias-chars-only, alias-max-length, alias-no-path-traversal, alias-url-http-only, alias-url-no-ftp, alias-url-max-length, alias-no-secrets, alias-no-open-redirect; speed: alias-create-fast |
| health | standard | config-infra | GET /health | app/features/health.py | - | cost: health-no-store; operability: health-reports-revision; speed: health-fast |
| home | standard | ui-page | GET / | app/features/home.pyapp/ui.py | home | behavior: home-renders, home-shows-version, home-headline-trusted; security: home-no-secrets; speed: home-fast |
| limits | standard | new-endpoint | GET /api/limits | app/features/limits.pytests/test_limits.py | limits | behavior: limits-returns-constants, limits-public-no-key; reliability: limits-reliable; security: limits-no-api-key-required, limits-no-secrets, limits-no-ip-logging, limits-constant-response, limits-no-request-body, limits-no-path-parameters, limits-no-query-parameters; speed: limits-fast |
| link-exists | standard | new-endpoint | GET /api/links/{code}/exists | app/features/link_exists.pytests/test_link_exists.py | link_exists | behavior: link-exists-true, link-exists-false, link-exists-no-url, link-exists-odd-code; reliability: link-exists-reliable; security: link-exists-no-url-leak, link-exists-odd-codes-safe, link-exists-long-codes-safe, link-exists-no-secrets, link-exists-public-no-key; speed: link-exists-fast |
| link-preview | experimental | ui-page | GET /p/{code} | app/features/link_preview.pytests/test_link_preview.py | link_preview | behavior: link-preview-shows-destination, link-preview-unknown-404, link-preview-no-secrets, link-preview-odd-code-404; security: preview-no-secrets, preview-no-api-key, preview-rejects-odd-codes, preview-html-escapes-destination; speed: link-preview-fast |
| links | standard | new-endpoint | POST /api/linksGET /api/links/{code}DELETE /api/links/{code} | app/features/links.py | - | behavior: link-create-read, link-delete; reliability: link-api-reliable; security: link-create-needs-key, link-http-only, link-url-well-formed; speed: link-details-fast |
| redirect | core | new-endpoint | GET /r/{code} | app/features/redirect.py | - | behavior: redirect-works, redirect-unknown-404; reliability: redirect-reliable; security: redirect-rejects-odd-codes; speed: redirect-fast |
| redirect-old-links | core | bug-fix | GET /r/{code} | tests/test_redirect.py | - | behavior: redirect-old-links-still-work |
| status-page | standard | ui-page | GET /statusGET /status/{rest:path} | app/features/status.py | - | behavior: status-forwards, status-rules-forward; security: status-no-secrets; speed: status-fast |
| version | standard | new-endpoint | GET /api/version | app/features/version.py | version | behavior: version-shows-revision; reliability: version-reliable; security: version-no-secrets; speed: version-fast |
Modules
app/__init__.py (python, 1 lines)
app/features/__init__.py (python, 3 lines)
app/features/custom_alias.py (python, 71 lines) · feature custom-alias
- route
POST /api/aliases -> create_alias() - class
NewAlias [letters_digits_dashes, http_only] :27 - def
create_alias(body, request) :65
app/features/health.py (python, 11 lines) · feature health
- route
GET /health -> health() - def
health(request) :9
app/features/home.py (python, 161 lines) · feature home
- route
GET / -> home() - def
home(request) :123
app/features/limits.py (python, 16 lines) · feature limits
- route
GET /api/limits -> limits() - def
limits() :14
app/features/link_exists.py (python, 22 lines) · feature link-exists
- route
GET /api/links/{code}/exists -> link_exists() - def
link_exists(code, request) :16
app/features/link_preview.py (python, 42 lines) · feature link-preview
- route
GET /p/{code} -> preview() - def
preview(code, request) :35
app/features/links.py (python, 77 lines) · feature links
- route
POST /api/links -> create_link() - route
GET /api/links/{code} -> get_link() - route
DELETE /api/links/{code} -> delete_link() - class
NewLink [http_only] :20 - def
valid_url(value) :29 - def
create_link(body, request) :54 - def
get_link(code, request) :66 - def
delete_link(code, request) :74
app/features/redirect.py (python, 22 lines) · feature redirect
- route
GET /r/{code} -> follow() - def
follow(code, request) :15
app/features/status.py (python, 23 lines) · feature status-page
- route
GET /status -> status_page() - route
GET /status/{rest:path} -> status_subpage() - def
status_page() :16 - def
status_subpage(rest) :21
app/features/version.py (python, 13 lines) · feature version
- route
GET /api/version -> version() - def
version(request) :11
app/flags.py (python, 46 lines)
- def
is_enabled(flag, store, revision) :27 - def
require(flag) :37
app/main.py (python, 77 lines)
- class
RevisionAndTiming :16 - def
discover_features() :53 - def
create_app(store) :63
app/security.py (python, 28 lines)
- def
api_key(request) :12 - def
require_api_key(request, x_api_key) :22
app/store.py (python, 106 lines)
- class
LinkExists :12 - class
MemoryStore [create, get, delete, read_doc, write_doc] :20 - class
FirestoreStore [create, get, delete, read_doc, write_doc] :49 - def
make_store() :99
app/telemetry.py (python, 37 lines)
- def
setup() :12 - def
log(severity, message) :22 - def
log_request(method, route, status, ms, revision) :26
app/ui.py (python, 64 lines) · feature home
- def
esc(value) :48 - def
header() :52 - def
page(title, body) :58
Routes
| Route | Defined in | Feature |
|---|---|---|
DELETE /api/links/{code} | app/features/links.py | links |
GET / | app/features/home.py | home |
GET /api/limits | app/features/limits.py | limits |
GET /api/links/{code} | app/features/links.py | links |
GET /api/links/{code}/exists | app/features/link_exists.py | link-exists |
GET /api/version | app/features/version.py | version |
GET /health | app/features/health.py | health |
GET /p/{code} | app/features/link_preview.py | link-preview |
GET /r/{code} | app/features/redirect.py | redirect |
GET /status | app/features/status.py | status-page |
GET /status/{rest:path} | app/features/status.py | status-page |
POST /api/aliases | app/features/custom_alias.py | custom-alias |
POST /api/links | app/features/links.py | links |
Tests
tests/__init__.py: 0 test(s)tests/conftest.py: 0 test(s)tests/test_app.py: 7 test(s)tests/test_cards.py: 6 test(s)tests/test_checker.py: 8 test(s)tests/test_custom_alias.py: 11 test(s)tests/test_desk.py: 1 test(s)tests/test_drive_logic.py: 7 test(s)tests/test_gate.py: 16 test(s)tests/test_gitlab_client.py: 2 test(s)tests/test_layer2.py: 12 test(s)tests/test_layer3.py: 73 test(s)tests/test_layer4.py: 20 test(s)tests/test_limits.py: 9 test(s)tests/test_link_exists.py: 12 test(s)tests/test_link_preview.py: 10 test(s)tests/test_redirect.py: 5 test(s)tests/test_state_notify_priority.py: 9 test(s)tests/test_version.py: 1 test(s)