entirius-django-siteintel 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- entirius_django_siteintel-0.1.0/.gitattributes +2 -0
- entirius_django_siteintel-0.1.0/.github/CODEOWNERS +1 -0
- entirius_django_siteintel-0.1.0/.github/workflows/ci.yml +51 -0
- entirius_django_siteintel-0.1.0/.github/workflows/publish.yml +20 -0
- entirius_django_siteintel-0.1.0/.gitignore +36 -0
- entirius_django_siteintel-0.1.0/.license-header.txt +3 -0
- entirius_django_siteintel-0.1.0/.pre-commit-config.yaml +39 -0
- entirius_django_siteintel-0.1.0/AGENTS.md +105 -0
- entirius_django_siteintel-0.1.0/CHANGELOG.md +41 -0
- entirius_django_siteintel-0.1.0/CLAUDE.md +1 -0
- entirius_django_siteintel-0.1.0/LICENSE +373 -0
- entirius_django_siteintel-0.1.0/Makefile +16 -0
- entirius_django_siteintel-0.1.0/PKG-INFO +40 -0
- entirius_django_siteintel-0.1.0/README.md +11 -0
- entirius_django_siteintel-0.1.0/docs/api.md +83 -0
- entirius_django_siteintel-0.1.0/docs/concept.md +123 -0
- entirius_django_siteintel-0.1.0/docs/erd-config.yaml +9 -0
- entirius_django_siteintel-0.1.0/docs/gotchas.md +74 -0
- entirius_django_siteintel-0.1.0/docs/install.md +80 -0
- entirius_django_siteintel-0.1.0/docs/openapi.yaml +490 -0
- entirius_django_siteintel-0.1.0/docs/operations.md +81 -0
- entirius_django_siteintel-0.1.0/docs/testing.md +26 -0
- entirius_django_siteintel-0.1.0/pyproject.toml +71 -0
- entirius_django_siteintel-0.1.0/src/django_siteintel/__init__.py +6 -0
- entirius_django_siteintel-0.1.0/src/django_siteintel/admin.py +68 -0
- entirius_django_siteintel-0.1.0/src/django_siteintel/api/__init__.py +0 -0
- entirius_django_siteintel-0.1.0/src/django_siteintel/api/admin/__init__.py +0 -0
- entirius_django_siteintel-0.1.0/src/django_siteintel/api/admin/urls.py +22 -0
- entirius_django_siteintel-0.1.0/src/django_siteintel/api/admin/views/__init__.py +0 -0
- entirius_django_siteintel-0.1.0/src/django_siteintel/api/admin/views/_base.py +50 -0
- entirius_django_siteintel-0.1.0/src/django_siteintel/api/admin/views/audit_views.py +126 -0
- entirius_django_siteintel-0.1.0/src/django_siteintel/api/admin/views/test_views.py +59 -0
- entirius_django_siteintel-0.1.0/src/django_siteintel/apps.py +11 -0
- entirius_django_siteintel-0.1.0/src/django_siteintel/enums.py +41 -0
- entirius_django_siteintel-0.1.0/src/django_siteintel/migrations/0001_initial.py +118 -0
- entirius_django_siteintel-0.1.0/src/django_siteintel/migrations/0002_audit_run_id_internal_error.py +40 -0
- entirius_django_siteintel-0.1.0/src/django_siteintel/migrations/0003_audit_one_in_flight_per_domain_channel.py +44 -0
- entirius_django_siteintel-0.1.0/src/django_siteintel/migrations/__init__.py +0 -0
- entirius_django_siteintel-0.1.0/src/django_siteintel/models/__init__.py +9 -0
- entirius_django_siteintel-0.1.0/src/django_siteintel/models/audit.py +39 -0
- entirius_django_siteintel-0.1.0/src/django_siteintel/models/external_api_key.py +17 -0
- entirius_django_siteintel-0.1.0/src/django_siteintel/models/report.py +28 -0
- entirius_django_siteintel-0.1.0/src/django_siteintel/schemas/__init__.py +0 -0
- entirius_django_siteintel-0.1.0/src/django_siteintel/schemas/requests.py +62 -0
- entirius_django_siteintel-0.1.0/src/django_siteintel/schemas/responses.py +56 -0
- entirius_django_siteintel-0.1.0/src/django_siteintel/security/__init__.py +7 -0
- entirius_django_siteintel-0.1.0/src/django_siteintel/security/url_guard.py +129 -0
- entirius_django_siteintel-0.1.0/src/django_siteintel/services/__init__.py +0 -0
- entirius_django_siteintel-0.1.0/src/django_siteintel/services/audit_service.py +165 -0
- entirius_django_siteintel-0.1.0/src/django_siteintel/services/cleaning_service.py +56 -0
- entirius_django_siteintel-0.1.0/src/django_siteintel/services/report_service.py +110 -0
- entirius_django_siteintel-0.1.0/src/django_siteintel/settings.py +61 -0
- entirius_django_siteintel-0.1.0/src/django_siteintel/signals/__init__.py +9 -0
- entirius_django_siteintel-0.1.0/src/django_siteintel/sources/__init__.py +0 -0
- entirius_django_siteintel-0.1.0/src/django_siteintel/sources/base.py +87 -0
- entirius_django_siteintel-0.1.0/src/django_siteintel/sources/heuristic.py +94 -0
- entirius_django_siteintel-0.1.0/src/django_siteintel/sources/lighthouse.py +101 -0
- entirius_django_siteintel-0.1.0/src/django_siteintel/sources/registry.py +40 -0
- entirius_django_siteintel-0.1.0/src/django_siteintel/sources/urlscan.py +81 -0
- entirius_django_siteintel-0.1.0/src/django_siteintel/tasks/__init__.py +12 -0
- entirius_django_siteintel-0.1.0/src/django_siteintel/tasks/expire_audits.py +13 -0
- entirius_django_siteintel-0.1.0/src/django_siteintel/tasks/finish_audit.py +29 -0
- entirius_django_siteintel-0.1.0/src/django_siteintel/tasks/poll_urlscan.py +30 -0
- entirius_django_siteintel-0.1.0/src/django_siteintel/tasks/run_audit.py +23 -0
- entirius_django_siteintel-0.1.0/src/django_siteintel/tasks/run_source.py +49 -0
- entirius_django_siteintel-0.1.0/src/django_siteintel/tasks/sweep_stuck_audits.py +13 -0
- entirius_django_siteintel-0.1.0/src/django_siteintel/urls.py +9 -0
- entirius_django_siteintel-0.1.0/src/django_siteintel/utils/__init__.py +0 -0
- entirius_django_siteintel-0.1.0/src/django_siteintel/utils/domains.py +46 -0
- entirius_django_siteintel-0.1.0/tests/__init__.py +3 -0
- entirius_django_siteintel-0.1.0/tests/conftest.py +97 -0
- entirius_django_siteintel-0.1.0/tests/fake_http.py +56 -0
- entirius_django_siteintel-0.1.0/tests/settings.py +58 -0
- entirius_django_siteintel-0.1.0/tests/test_admin.py +56 -0
- entirius_django_siteintel-0.1.0/tests/test_admin_api.py +143 -0
- entirius_django_siteintel-0.1.0/tests/test_audit_service.py +243 -0
- entirius_django_siteintel-0.1.0/tests/test_domains.py +34 -0
- entirius_django_siteintel-0.1.0/tests/test_migrations.py +44 -0
- entirius_django_siteintel-0.1.0/tests/test_package.py +23 -0
- entirius_django_siteintel-0.1.0/tests/test_sources.py +135 -0
- entirius_django_siteintel-0.1.0/tests/test_tasks.py +204 -0
- entirius_django_siteintel-0.1.0/tests/test_url_guard.py +80 -0
- entirius_django_siteintel-0.1.0/tests/urls.py +7 -0
- entirius_django_siteintel-0.1.0/uv.lock +1443 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
* @entirius/maintainers-backend
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Workflow of entirius-django-siteintel (GitHub org entirius).
|
|
2
|
+
name: CI
|
|
3
|
+
|
|
4
|
+
on:
|
|
5
|
+
push:
|
|
6
|
+
branches: [develop]
|
|
7
|
+
pull_request:
|
|
8
|
+
branches: [master, develop]
|
|
9
|
+
workflow_dispatch:
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
lint:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
- uses: astral-sh/setup-uv@v4
|
|
17
|
+
- run: uv sync --frozen --all-extras
|
|
18
|
+
- run: uv run ruff check .
|
|
19
|
+
- run: uv run ruff format --check .
|
|
20
|
+
- run: uv run pre-commit run insert-license --all-files
|
|
21
|
+
|
|
22
|
+
test:
|
|
23
|
+
runs-on: ubuntu-latest
|
|
24
|
+
needs: lint
|
|
25
|
+
services:
|
|
26
|
+
postgres:
|
|
27
|
+
image: postgres:16-alpine
|
|
28
|
+
env:
|
|
29
|
+
POSTGRES_PASSWORD: postgres
|
|
30
|
+
ports: ['5432:5432']
|
|
31
|
+
options: >-
|
|
32
|
+
--health-cmd pg_isready --health-interval 5s --health-timeout 5s --health-retries 5
|
|
33
|
+
env:
|
|
34
|
+
DATABASE_URL: postgresql://postgres:postgres@localhost/test
|
|
35
|
+
steps:
|
|
36
|
+
- uses: actions/checkout@v4
|
|
37
|
+
- uses: astral-sh/setup-uv@v4
|
|
38
|
+
- run: uv sync --frozen --all-extras
|
|
39
|
+
- run: uv run pytest -x -q
|
|
40
|
+
|
|
41
|
+
secret-scan:
|
|
42
|
+
runs-on: ubuntu-latest
|
|
43
|
+
steps:
|
|
44
|
+
- uses: actions/checkout@v4
|
|
45
|
+
with:
|
|
46
|
+
fetch-depth: 0
|
|
47
|
+
- name: gitleaks
|
|
48
|
+
run: |
|
|
49
|
+
V=v8.30.0 # keep equal to the gitleaks rev in .pre-commit-config.yaml
|
|
50
|
+
curl -sSL "https://github.com/gitleaks/gitleaks/releases/download/${V}/gitleaks_${V#v}_linux_x64.tar.gz" | sudo tar -xz -C /usr/local/bin gitleaks
|
|
51
|
+
gitleaks git --redact -v
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Workflow of entirius-django-siteintel (GitHub org entirius).
|
|
2
|
+
name: Publish
|
|
3
|
+
|
|
4
|
+
on:
|
|
5
|
+
workflow_dispatch:
|
|
6
|
+
release:
|
|
7
|
+
types: [published]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
publish:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
environment: pypi # GH environment bound to the PyPI trusted publisher
|
|
13
|
+
permissions:
|
|
14
|
+
id-token: write # OIDC - short-lived PyPI token, no stored secrets
|
|
15
|
+
contents: read
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
- uses: astral-sh/setup-uv@v4
|
|
19
|
+
- run: uv build
|
|
20
|
+
- run: uv publish --trusted-publishing always
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.egg-info/
|
|
5
|
+
build/
|
|
6
|
+
dist/
|
|
7
|
+
|
|
8
|
+
# Virtualenv / uv
|
|
9
|
+
.venv/
|
|
10
|
+
.python-version
|
|
11
|
+
|
|
12
|
+
# Django (test project artifacts)
|
|
13
|
+
db.sqlite3
|
|
14
|
+
db.sqlite3-journal
|
|
15
|
+
*.log
|
|
16
|
+
|
|
17
|
+
# Test / coverage
|
|
18
|
+
.pytest_cache/
|
|
19
|
+
.coverage
|
|
20
|
+
htmlcov/
|
|
21
|
+
coverage.xml
|
|
22
|
+
|
|
23
|
+
# Tooling caches
|
|
24
|
+
.ruff_cache/
|
|
25
|
+
.mypy_cache/
|
|
26
|
+
|
|
27
|
+
# IDE / OS
|
|
28
|
+
.idea/
|
|
29
|
+
.vscode/
|
|
30
|
+
.DS_Store
|
|
31
|
+
|
|
32
|
+
# Secret scanning (forbidden-names blocklist - local symlink, never committed)
|
|
33
|
+
.gitleaks.toml
|
|
34
|
+
|
|
35
|
+
# Local gitleaks symlink (canonical config lives outside the repo)
|
|
36
|
+
.gitleaks.toml
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
repos:
|
|
2
|
+
- repo: https://github.com/Lucas-C/pre-commit-hooks
|
|
3
|
+
rev: v1.5.6
|
|
4
|
+
hooks:
|
|
5
|
+
- id: insert-license
|
|
6
|
+
files: \.py$
|
|
7
|
+
exclude: (^|/)__init__\.py$
|
|
8
|
+
args:
|
|
9
|
+
- --license-filepath
|
|
10
|
+
- .license-header.txt
|
|
11
|
+
- --comment-style
|
|
12
|
+
- "#"
|
|
13
|
+
|
|
14
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
15
|
+
rev: v0.15.20
|
|
16
|
+
hooks:
|
|
17
|
+
- id: ruff-check
|
|
18
|
+
args: [--fix]
|
|
19
|
+
- id: ruff-format
|
|
20
|
+
|
|
21
|
+
- repo: local
|
|
22
|
+
hooks:
|
|
23
|
+
- id: require-canonical-gitleaks-config
|
|
24
|
+
name: require canonical .gitleaks.toml (forbidden-names)
|
|
25
|
+
entry: bash -c 'grep -q "forbidden-names" .gitleaks.toml 2>/dev/null || { echo "Missing or non-canonical .gitleaks.toml - symlink the config per the internal secret-scanning standard"; exit 1; }'
|
|
26
|
+
language: system
|
|
27
|
+
always_run: true
|
|
28
|
+
pass_filenames: false
|
|
29
|
+
- id: gitleaks-config-untracked
|
|
30
|
+
name: .gitleaks.toml must stay gitignored
|
|
31
|
+
entry: bash -c '! git ls-files --error-unmatch .gitleaks.toml 2>/dev/null || { echo ".gitleaks.toml is tracked - add it to .gitignore"; exit 1; }'
|
|
32
|
+
language: system
|
|
33
|
+
always_run: true
|
|
34
|
+
pass_filenames: false
|
|
35
|
+
|
|
36
|
+
- repo: https://github.com/gitleaks/gitleaks
|
|
37
|
+
rev: v8.30.0
|
|
38
|
+
hooks:
|
|
39
|
+
- id: gitleaks
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# AGENTS.md
|
|
2
|
+
|
|
3
|
+
entirius-django-siteintel — domain intelligence for Volkanos: PageSpeed Insights, urlscan.io and a heuristic
|
|
4
|
+
fetch per registrable domain, reused while valid, announced by one signal. App label `django_siteintel`,
|
|
5
|
+
table prefix `django_siteintel_`.
|
|
6
|
+
|
|
7
|
+
## Quick Reference
|
|
8
|
+
|
|
9
|
+
- Python ≥ 3.11, Django ≥ 4.2, DRF + simplejwt + drf-spectacular, Pydantic 2, Celery, PostgreSQL, `uv`, ruff,
|
|
10
|
+
hatchling, MPL-2.0.
|
|
11
|
+
- Read first: `docs/install.md` (host) · `docs/api.md` (caller) · `docs/concept.md` (why) ·
|
|
12
|
+
`docs/gotchas.md` (before editing). This file is the map; it explains nothing twice.
|
|
13
|
+
|
|
14
|
+
## Commands
|
|
15
|
+
|
|
16
|
+
| Command | Meaning |
|
|
17
|
+
|---|---|
|
|
18
|
+
| `make install` | `uv sync --all-extras` |
|
|
19
|
+
| `make test` | pytest — Postgres only, see Testing |
|
|
20
|
+
| `make check` / `fix` | ruff lint + format (+ canonical `.gitleaks.toml` guard) |
|
|
21
|
+
| in zeno: `make module-test MODULE=entirius-django-siteintel` | the same suite inside the service container |
|
|
22
|
+
|
|
23
|
+
## Conventions
|
|
24
|
+
|
|
25
|
+
- English only; MPL-2.0 header on every `.py` (`insert-license`); no Claude attribution trailers.
|
|
26
|
+
- Layered: `models/` · `sources/` (fetch → validate → process) · `services/` · `schemas/` · `api/admin/` ·
|
|
27
|
+
`tasks/`. No logic in models; the API never exposes `Report.raw` or key values.
|
|
28
|
+
- No imports from leads, communicator or catalog modules — consumers call `request_audit` and listen to
|
|
29
|
+
`report_ready`.
|
|
30
|
+
- Never rename the package, the app label or the table prefix; never edit a released migration.
|
|
31
|
+
- Git flow: `develop` + `master`, PRs. Do not commit by default — the operator decides.
|
|
32
|
+
|
|
33
|
+
## Map
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
src/django_siteintel/
|
|
37
|
+
├── apps.py enums.py (statuses, ErrorCode) settings.py (value(), clamped poll settings, recording_mode)
|
|
38
|
+
├── models/ audit.py (Audit, run_id) report.py (Report) external_api_key.py
|
|
39
|
+
├── schemas/ requests.py responses.py
|
|
40
|
+
├── api/admin/ urls.py views/_base.py (AdminView: JWT + IsAdminUser) audit_views.py test_views.py (development)
|
|
41
|
+
├── urls.py api/siteintel/v2/admin/<channel_idx>/ → api.admin.urls
|
|
42
|
+
├── migrations/ 0001 initial · 0002 Audit.run_id + ErrorCode.internal
|
|
43
|
+
├── sources/ base.py (SourceFetcher, SourceError — the contract) registry.py (entry points `siteintel_sources`)
|
|
44
|
+
│ lighthouse.py (PSI v5) urlscan.py (submit + poll) heuristic.py (own fetch)
|
|
45
|
+
├── services/ audit_service (request, rerun, expire, sweep, run_now) report_service (run, poll, fail, finish)
|
|
46
|
+
│ cleaning_service (snapshot trimming, NUL strip)
|
|
47
|
+
├── security/ url_guard.py (safe_get, safe_post — a copy of lookup's guard)
|
|
48
|
+
├── signals/ report_ready(audit, succeeded_sources)
|
|
49
|
+
├── tasks/ run_audit run_source poll_urlscan finish_audit expire_audits sweep_stuck_audits
|
|
50
|
+
├── utils/ domains.py (registrable domain, 2048-char URL bound)
|
|
51
|
+
└── admin.py Audit (+ report inline, no raw), ExternalApiKey (masked in the list)
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Flow: `request_audit` → reuse a valid audit of the domain in the channel (`report_ready` at once) or create
|
|
55
|
+
`Audit` + one `Report` per source → `run_audit` → chord of `run_source` (`poll_urlscan` for urlscan) →
|
|
56
|
+
`finish_audit` → status + `report_ready` once per run.
|
|
57
|
+
|
|
58
|
+
## Where things live
|
|
59
|
+
|
|
60
|
+
| Question | Answer |
|
|
61
|
+
|---|---|
|
|
62
|
+
| A setting's name, default, meaning | `settings.py`; the table in `docs/install.md` |
|
|
63
|
+
| Request / response shape, auth, errors | `docs/api.md`; `schemas/`; `docs/openapi.yaml` |
|
|
64
|
+
| The source protocol, recording mode | `sources/base.py`; `docs/concept.md` § Sources |
|
|
65
|
+
| What a status or an `error_code` means | `enums.py`; `docs/concept.md` § Lifecycle; `docs/operations.md` § Reading a failed report |
|
|
66
|
+
| Why reuse, rerun, expiry and the sweeper behave as they do | `docs/concept.md` § Reuse, rerun, expiry |
|
|
67
|
+
| Tasks, schedules, the SSRF guard, adding a source | `docs/operations.md` |
|
|
68
|
+
| Snapshot size rules | `services/cleaning_service.py`; `docs/concept.md` § Snapshot cleaning |
|
|
69
|
+
| Which test file covers what | `docs/testing.md` |
|
|
70
|
+
| What changed and why | `CHANGELOG.md` |
|
|
71
|
+
| ERD groupings | `docs/erd-config.yaml` |
|
|
72
|
+
|
|
73
|
+
## Testing
|
|
74
|
+
|
|
75
|
+
- Postgres only (`tests/settings.py`): `DATABASE_URL` wins (zeno container), else
|
|
76
|
+
`postgresql://entirius:entirius-dev@localhost:5532/entirius`. Migrations run in tests.
|
|
77
|
+
- HTTP is faked (`tests/fake_http.py`); `recordings` in `tests/conftest.py` serves PSI / urlscan answers for
|
|
78
|
+
`example-shop-1.test`. Celery runs eagerly where a test needs the chord (`eager_celery`).
|
|
79
|
+
- `ENVIRONMENT = "development"` in test settings — the `test/` routes are mounted at import.
|
|
80
|
+
|
|
81
|
+
## Testing end-to-end
|
|
82
|
+
|
|
83
|
+
| ID | Unit (`tests/`) | BDD (emporium `features/siteintel/siteintel_audit.feature`) |
|
|
84
|
+
|---|---|---|
|
|
85
|
+
| S-01 reuse of a valid audit, no fetch | `test_audit_service` (+ channel scope) | yes |
|
|
86
|
+
| S-02 expired audit → new audit, history kept | `test_audit_service` | — |
|
|
87
|
+
| S-03 PSI 429/5xx → retries → partially completed | `test_tasks` | — |
|
|
88
|
+
| S-04 urlscan poll budget → timeout, no sleep | `test_tasks` | — |
|
|
89
|
+
| S-05 private host / redirect to 10.x refused | `test_url_guard` | — |
|
|
90
|
+
| S-06 page over the byte cap → partial(truncated) | `test_url_guard` | — |
|
|
91
|
+
| S-07 base64 stripped, lists trimmed, < 64 KB | `test_sources` | — |
|
|
92
|
+
| S-08 heuristic differs per synthetic site | `test_sources` | yes |
|
|
93
|
+
| S-09 re-audit refreshes reports (409 while running) | `test_audit_service`, `test_admin_api` | yes |
|
|
94
|
+
|
|
95
|
+
- `make bdd TAGS=@siteintel` in zeno. Not one-shot: the Background expires every valid audit through
|
|
96
|
+
`test/expire-now/`, so the feature re-runs on one seed. Recordings: emporium `fixtures/siteintel/`;
|
|
97
|
+
zeno points both base URLs at the `fixtures` container (recording mode).
|
|
98
|
+
- The module also runs inside the leads funnel (`@funnel`, one-shot per seed): stage rule → audit →
|
|
99
|
+
`report_ready` → intel. Guides: portal `guides/leads-end-to-end-testing.md`, emporium
|
|
100
|
+
`docs/e2e-leads-funnel.md`.
|
|
101
|
+
- Restart the worker after task changes — Celery has no autoreload.
|
|
102
|
+
|
|
103
|
+
## Gotchas
|
|
104
|
+
|
|
105
|
+
`docs/gotchas.md` — the only list. Read it before touching tasks, sources, the guard or the API.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0 — 2026-09-15
|
|
4
|
+
|
|
5
|
+
First release. Domain intelligence for Volkanos: one audit per registrable domain and channel, one cleaned
|
|
6
|
+
report per source, reused while valid, announced by the `report_ready` signal.
|
|
7
|
+
|
|
8
|
+
- **Audits and reports.** `Audit` keyed by registrable domain (eTLD+1 from a short multi-part suffix list,
|
|
9
|
+
never substring matching), `Report` unique per audit and source, `ExternalApiKey` per source.
|
|
10
|
+
`audit_service.request_audit` reuses the newest valid audit of the domain in the same channel — nothing is
|
|
11
|
+
fetched and `report_ready` is sent at once — or creates a pending audit with one report per source.
|
|
12
|
+
`rerun_audit` keeps the id and resets the reports (refused while running); `expire_audits` keeps history.
|
|
13
|
+
- **Sources** through the entry-point group `siteintel_sources`: PageSpeed Insights v5 (mobile and desktop;
|
|
14
|
+
key in the `X-Goog-Api-Key` header), urlscan.io (submit, then countdown polling — no sleep in the worker),
|
|
15
|
+
and a heuristic fetch of the page (title, meta, images without alt, inline scripts, bytes, redirects,
|
|
16
|
+
viewport). Recording mode reads `{base}/{domain}.{strategy}.json` when a base URL is not the public API.
|
|
17
|
+
- **Run lifecycle** on queue `siteintel_default`: `run_audit` → chord of `run_source` → `finish_audit`,
|
|
18
|
+
`report_ready` once per run. Only `upstream` errors retry (3×, backoff); any unexpected exception fails the
|
|
19
|
+
report `internal` so the chord always completes. Every task carries the audit's `run_id` and ignores a run
|
|
20
|
+
a rerun replaced. `sweep_stuck_audits` (beat, 10 min) fails audits pending or running longer than
|
|
21
|
+
`SITEINTEL_AUDIT_STUCK_MINUTES` and signals once. Poll interval and budget are clamped at read time.
|
|
22
|
+
- **Safety.** SSRF guard on every outbound request (every redirect hop re-validated, headers never sent to
|
|
23
|
+
another host, body capped); `processed` snapshots stripped of base64 and screenshots, lists trimmed, bounded
|
|
24
|
+
to 64 KB; NUL characters removed before save; `raw` and keys never returned.
|
|
25
|
+
- **Admin API v2** under `api/siteintel/v2/admin/<channel_idx>/`: list, detail, request (201 new / 200 reused;
|
|
26
|
+
400 for a URL over 2048 characters), rerun (202; 409 while running). Development-only `test/run-now/` and
|
|
27
|
+
`test/expire-now/`.
|
|
28
|
+
- **Docs.** `docs/` — `concept.md`, `install.md`, `api.md`, `operations.md`, `gotchas.md`, `testing.md`,
|
|
29
|
+
`openapi.yaml`, `erd-config.yaml`.
|
|
30
|
+
- **Edge cases covered:** S-01 … S-09 in the unit suite; S-01, S-08, S-09 also in the emporium BDD feature
|
|
31
|
+
`@siteintel`.
|
|
32
|
+
- **Fix: `ExternalApiKey` admin change form no longer renders the stored key in plain text.** The key is a
|
|
33
|
+
write-only field (`new_key`, `PasswordInput`); leaving it blank on save keeps the stored value. The add
|
|
34
|
+
form requires it, so no empty key is created.
|
|
35
|
+
- **Fix: one in-flight audit per (domain, channel).** A database constraint (migration `0003`) rejects a
|
|
36
|
+
second `pending`/`running` `Audit` row for the same domain and channel; `request_audit` catches the race
|
|
37
|
+
and returns the winning audit instead of creating a duplicate (never `None`: a winner that already finished is
|
|
38
|
+
found as the valid or newest audit). The migration first fails all but the newest duplicate in-flight audit.
|
|
39
|
+
A rerun that would put a second audit in flight answers 409 `audit_in_flight` instead of a 500.
|
|
40
|
+
- **Fix: a lost `pending` audit no longer blocks its domain.** `sweep_stuck_audits` fails `pending` audits
|
|
41
|
+
older than `SITEINTEL_AUDIT_STUCK_MINUTES` too.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@AGENTS.md
|