docs(professional-audit): community health, CodeQL, docs truthfulness
Second audit round, findings fixed: - ROADMAP was two versions stale: v1.3 still labelled 'current work', the plans feature absent. All shipped sections now carry their version, open work lives under 'next — current work' with real issue numbers (#29/#30/#31) and the two pending experiments - architecture.md Quota section documented only the v1.3 monthly allowance; now covers the full plans system: free/pro table, both 402 codes, expiry downgrade, stacked renewals, admin endpoint and the deliberate no-payment-gateway design (all claims verified against limits.py/deps.py/routes_admin.py/handlers.py) - CODE_OF_CONDUCT.md (Contributor Covenant 2.1) + CODEOWNERS — community profile previously missing both - CodeQL workflow: weekly + per-push SAST over Python (security-extended) and web, results in the Security tab - .env.example: WEBHOOK_TIMEOUT_SECONDS / WEBHOOK_ATTEMPTS existed in Settings but were undocumented - landing page: transparent-quota feature card (headline feature of v1.4.0 was absent from the product face) - CHANGELOG Unreleased section documents all of the above Validated: YAML parses, HTML tag balance, linkcheck 25/25, CI green on the previous commit.
This commit is contained in:
1 parent
44ebd69090
commit
3d74253a58
8 files changed
+221
-26
No files matched your search
@@ -113,6 +113,12 @@ NEXT_PUBLIC_API_BASE=http://localhost:8000
|
||||
# older than five minutes. Leave empty to deliver callbacks unsigned.
|
||||
WEBHOOK_SIGNING_SECRET=
|
||||
|
||||
# Webhook delivery tuning: seconds per delivery attempt and how many
|
||||
# attempts are made before the callback is dropped (delivery is
|
||||
# best-effort and never flips the job status).
|
||||
WEBHOOK_TIMEOUT_SECONDS=4.0
|
||||
WEBHOOK_ATTEMPTS=2
|
||||
|
||||
# --- Deployment (deploy/docker-compose.yml) ---
|
||||
# Required: the compose file refuses to start without a real password.
|
||||
POSTGRES_PASSWORD=change-me-to-a-long-random-value
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
# Default: the maintainer reviews everything.
|
||||
# Per-area owners can be added as the team grows, e.g.:
|
||||
# /web/ @someone
|
||||
* @Abolfazlrwm
|
||||
@@ -0,0 +1,51 @@
|
||||
name: CodeQL
|
||||
|
||||
# Static security analysis (SAST) of the Python backend/bot and the
|
||||
# Next.js dashboard. Results land in the repo's Security tab under
|
||||
# "Code scanning" so vulnerabilities are visible, not guessed.
|
||||
# Free for public repositories.
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
schedule:
|
||||
# Weekly scan on top of every push: catches newly discovered
|
||||
# patterns in dependencies that never changed.
|
||||
- cron: "17 4 * * 1"
|
||||
|
||||
permissions:
|
||||
security-events: write
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze (${{ matrix.language }})
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- language: python
|
||||
paths: backend bot training benchmarks space deploy
|
||||
- language: javascript-typescript
|
||||
paths: web
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v3
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
# "none" build mode: modern CodeQL extracts JS/TS without a build;
|
||||
# Python needs no build either.
|
||||
build-mode: none
|
||||
queries: security-extended
|
||||
- if: matrix.language == 'javascript-typescript'
|
||||
name: Install web deps for extraction
|
||||
working-directory: web
|
||||
run: npm ci
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v3
|
||||
with:
|
||||
category: "/language:${{ matrix.language }}"
|
||||
+24
-2
@@ -7,11 +7,33 @@ The format follows [Keep a Changelog](https://keepachangelog.com/) and the proje
|
||||
|
||||
### Added
|
||||
|
||||
- `CITATION.cff` so the project can be cited in academic work
|
||||
- FastAPI app metadata: MIT license info is now rendered on `/docs`
|
||||
- `CODE_OF_CONDUCT.md` (Contributor Covenant 2.1, Persian-and-English
|
||||
friendly) and a `CODEOWNERS` file — the GitHub community profile now
|
||||
lists every recommended community health file
|
||||
- A `CodeQL` workflow: weekly + per-push static security analysis of the
|
||||
Python packages (security-extended queries) and the web dashboard,
|
||||
results visible in the Security tab's code scanning
|
||||
- `WEBHOOK_TIMEOUT_SECONDS` and `WEBHOOK_ATTEMPTS` documented in
|
||||
`.env.example` (the Settings existed; the example file did not list
|
||||
them)
|
||||
|
||||
### Changed
|
||||
|
||||
- `docs/ROADMAP.md` was two versions stale: v1.3 was still labelled
|
||||
"current work" and the plans feature was absent. Sections are now
|
||||
marked shipped with their versions, plans/quota are documented as a
|
||||
shipped item, and a "next — current work" section ties the open good
|
||||
first issues and the scaled fine-tune to real issue numbers
|
||||
- `docs/architecture.md`: the Quota section only described the v1.3
|
||||
monthly allowance; it now documents the full plans system (free/pro
|
||||
table, both HTTP 402 codes, expiry downgrade, stacked renewals, the
|
||||
admin endpoint, and the deliberate no-payment-gateway design)
|
||||
- The landing page feature grid now includes the transparent-quota card
|
||||
(free/pro limits and the honest 402 responses) — the headline feature
|
||||
of v1.4.0 was missing from the public product face
|
||||
- `CITATION.cff` so the project can be cited in academic work
|
||||
- FastAPI app metadata: MIT license info is now rendered on `/docs`
|
||||
|
||||
- Backend and bot package versions are dynamic now — they track
|
||||
`__version__` (single source of truth, currently 1.4.0) instead of the
|
||||
stale hardcoded `0.1.0` — and both carry full PEP 621 metadata:
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our pledge
|
||||
|
||||
Everyone participating in the Sokhan project — issues, pull requests,
|
||||
Discussions, the Telegram group, the Hugging Face Space — is expected to
|
||||
keep the space harassment-free, regardless of age, body size, visible or
|
||||
invisible disability, ethnicity, sex characteristics, gender identity and
|
||||
expression, level of experience, education, socio-economic status,
|
||||
nationality, personal appearance, race, religion, or sexual identity and
|
||||
orientation. Persian and English are both welcome; write in whichever you
|
||||
prefer.
|
||||
|
||||
## Our standards
|
||||
|
||||
Positive behavior includes using welcoming language, being patient with
|
||||
newcomers, publishing reproducible measurements when making claims, and
|
||||
gracefully accepting constructive criticism. Unacceptable behavior
|
||||
includes trolling, insulting or derogatory comments, personal or
|
||||
political attacks, public or private harassment, publishing other
|
||||
people's private information without consent, and any conduct a
|
||||
reasonable person would consider inappropriate in a professional
|
||||
setting.
|
||||
|
||||
## Responsibilities
|
||||
|
||||
Maintainers are responsible for clarifying the standards and for taking
|
||||
fair, corrective action in response to any unacceptable behavior, and
|
||||
have the right and responsibility to remove, edit, or reject comments,
|
||||
commits, code, issues, and other contributions that violate this Code of
|
||||
Conduct.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies within all project spaces and when an
|
||||
individual represents the project publicly (for example, using the
|
||||
project's name on Hugging Face or social media).
|
||||
|
||||
## Enforcement
|
||||
|
||||
Report abusive, harassing, or otherwise unacceptable behavior privately
|
||||
via GitHub's [private vulnerability reporting][pvr] channel (choose
|
||||
"Report a vulnerability" in the Security tab — it reaches the maintainer
|
||||
directly and stays confidential), or through a direct message to
|
||||
[@Abolfazlrwm](https://github.com/Abolfazlrwm). All complaints are
|
||||
reviewed and answered; maintainers bound by confidentiality will
|
||||
investigate. Violations can result in a temporary or permanent ban from
|
||||
project spaces.
|
||||
|
||||
[pvr]: https://github.com/Abolfazlrwm/sokhan/security/advisories/new
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the
|
||||
[Contributor Covenant][homepage], version 2.1.
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
+46
-19
@@ -5,7 +5,7 @@ below: **a claim ships only with a measurement** (WER from
|
||||
`benchmarks/benchmark_wer.py` on the fixed fixture, or a test that
|
||||
reproduces it). Dated entries move to `CHANGELOG.md` when they land.
|
||||
|
||||
## v1.3 — public face (current work)
|
||||
## v1.3 — public face (shipped, v1.3.0)
|
||||
|
||||
- [x] Demo app (`space/`) — RTL Persian UI, mic + file + bundled sample
|
||||
clip. Shipped in two flavors: the free **Static Space** runs Whisper
|
||||
@@ -21,22 +21,11 @@ reproduces it). Dated entries move to `CHANGELOG.md` when they land.
|
||||
5.0 s wall) — https://huggingface.co/spaces/Abol0pati/sokhan-fa-demo
|
||||
- [x] Model card on the whisper-small repo (the tiny repo already had
|
||||
one): measured numbers, honest caveats, usage snippet
|
||||
- [ ] **The scaled fine-tune.** The v1.2.0 run (500 clips) beat the
|
||||
baseline by 1.2 WER points — at the edge of the fixture's noise
|
||||
floor. The same notebook at `MAX_SAMPLES = 0` (~10 h of speech,
|
||||
~2 h on a free T4) is the single highest-value experiment left in
|
||||
the training kit. After it: re-benchmark, update the model card,
|
||||
and publish the new checkpoint — then the 500-clip run becomes the
|
||||
ablation row.
|
||||
- [ ] **Fine-tuned checkpoint in the browser.** Upload the merged HF
|
||||
weights (notebook cell 11; the merged folder only exists right
|
||||
after a training run), export ONNX, and point the client-side demo
|
||||
at it — the free Static Space would then demo the *fine-tuned*
|
||||
model with zero hosting cost.
|
||||
- [ ] A bigger eval fixture (target: 200 clips, stratified by age/gender
|
||||
and accent bands) so WER deltas stop being noise-limited
|
||||
|
||||
## v1.4 — engine quality
|
||||
The open items below moved to [next — current work](#next--current-work)
|
||||
when v1.4.0 shipped.
|
||||
|
||||
## v1.4 — engine quality (shipped, v1.4.0)
|
||||
|
||||
- [x] Streaming/chunked decode in the worker: the pipeline streams PyAV
|
||||
blocks and emits the same 30-second windows from the block stream —
|
||||
@@ -59,8 +48,13 @@ reproduces it). Dated entries move to `CHANGELOG.md` when they land.
|
||||
- [x] Benchmark regression gate: the weekly `benchmark.yml` workflow runs
|
||||
the fixture against `benchmarks/results/baseline.json` and fails if
|
||||
`small` WER degrades > 1 point (guards engine/dependency upgrades)
|
||||
- [x] Release-grade packaging: dynamic package versions driven by
|
||||
`__version__`, full PEP 621 metadata on both Python packages, MIT
|
||||
`license_info` on `/docs`, `CITATION.cff` for academic citation, and
|
||||
`deploy/docker-compose.yml` passing the plan/admin variables through
|
||||
so every compose deployment is feature-complete (v1.4.0)
|
||||
|
||||
## v1.5 — product surface
|
||||
## v1.5 — product surface (shipped in v1.4.0)
|
||||
|
||||
- [x] Notify when a job finishes — the Telegram bot now pushes the
|
||||
transcript (or a failure notice) the moment the backend completes, and
|
||||
@@ -73,13 +67,46 @@ reproduces it). Dated entries move to `CHANGELOG.md` when they land.
|
||||
JSON export and verbose_json, flagged with `⚠` in SRT/VTT/DOCX below
|
||||
`LOW_CONFIDENCE_THRESHOLD` and badged "needs review" in the dashboard —
|
||||
human reviewers know exactly where to re-listen
|
||||
- Speaker identification on top of diarization (ADR 0003/0004 define the
|
||||
interface; pyannote is the default neural engine today)
|
||||
- [ ] Speaker identification on top of diarization (ADR 0003/0004 define
|
||||
the interface; pyannote is the default neural engine today)
|
||||
- [x] Docker image publish to GHCR so self-hosting skips the build step:
|
||||
`docker.yml` builds `sokhan-api` (serves the API and, with the Celery
|
||||
command override, the worker) and `sokhan-web` on every push to `main`
|
||||
and every version tag
|
||||
|
||||
- [x] Plans & quotas: two tiers out of the box — **Free** (10-minute
|
||||
files, 30 minutes/month) and **Pro** (180-minute files, 1200
|
||||
minutes/month) — enforced as honest HTTP 402 responses
|
||||
(`quota_exceeded` / `file_too_long`), with expiry-based downgrade,
|
||||
stacked renewals, and operator-issued subscriptions via
|
||||
`POST /admin/users/{email}/plan` (`X-Admin-Key`, constant-time
|
||||
compare; no payment gateway by design — see CHANGELOG 1.4.0)
|
||||
- [x] Dashboard and bot respect the plans: the bot answers `/quota`,
|
||||
shows a `/upgrade` catalogue, and rejects over-cap voices before
|
||||
upload; the dashboard renders the 402 limits
|
||||
|
||||
## next — current work
|
||||
|
||||
The open [good-first-issues](https://github.com/Abolfazlrwm/sokhan/issues)
|
||||
plus the highest-value experiments:
|
||||
|
||||
- [ ] **The scaled fine-tune.** The v1.2.0 run (500 clips) beat the
|
||||
baseline by 1.2 WER points — at the edge of the fixture's noise
|
||||
floor. The same notebook at `MAX_SAMPLES = 0` (~10 h of speech,
|
||||
~2 h on a free T4) is the single highest-value experiment left in the
|
||||
training kit. After it: re-benchmark, update the model card, publish
|
||||
the new checkpoint — then the 500-clip run becomes the ablation row
|
||||
- [ ] **Fine-tuned checkpoint in the browser.** Upload the merged HF
|
||||
weights (notebook cell 11), export ONNX, and point the client-side
|
||||
demo at it — the free Static Space would then demo the *fine-tuned*
|
||||
model with zero hosting cost
|
||||
- [ ] Extend the benchmark fixture beyond 12 clips (issue #29, target:
|
||||
200 clips stratified by age/gender and accent bands) so WER deltas
|
||||
stop being noise-limited
|
||||
- [ ] Punctuation post-pass: cover the edge cases the fixture exposes
|
||||
(issue #30)
|
||||
- [ ] Translate CONTRIBUTING.md to Persian (issue #31)
|
||||
|
||||
## v2.0 — direction candidates (decide by measurement, not vibes)
|
||||
|
||||
- Persian TTS — the mirror of STT, completing "speech" in the name
|
||||
|
||||
+29
-5
@@ -110,12 +110,36 @@ by spaces so phrase queries match the punctuated transcripts). SQLite falls back
|
||||
`ILIKE`; Postgres adds a `pg_trgm` GIN index plus similarity scoring, created
|
||||
idempotently at startup (`ensure_postgres_search_objects`).
|
||||
|
||||
## Quota
|
||||
## Quota and plans
|
||||
|
||||
`FREE_MINUTES_PER_USER_PER_MONTH` (default 30) is enforced from the
|
||||
`usage_records` table: once a user's current-month total reaches the limit,
|
||||
uploads and OpenAI-compatible calls return HTTP 402 with the used and
|
||||
remaining minutes in the body. Rejections are transparent, not silent.
|
||||
Two plans out of the box, tuned through `PLAN_*` environment variables:
|
||||
|
||||
| | Free (default) | Pro |
|
||||
| --- | --- | --- |
|
||||
| Max file length | 10 min (`PLAN_FREE_MAX_FILE_MINUTES`) | 180 min (`PLAN_PRO_MAX_FILE_MINUTES`) |
|
||||
| Monthly minutes | 30 (`FREE_MINUTES_PER_USER_PER_MONTH`) | 1200 (`PLAN_PRO_MONTHLY_MINUTES`) |
|
||||
|
||||
Enforcement lives in the API layer:
|
||||
|
||||
- The **monthly quota** is computed from the `usage_records` table (per
|
||||
user, current month). Once the total reaches the plan's allowance,
|
||||
uploads and OpenAI-compatible calls return HTTP 402 with code
|
||||
`quota_exceeded`, plus the used and remaining minutes in the body.
|
||||
- The **per-file cap** is checked against the probed audio duration
|
||||
before the job is queued; over-cap files return HTTP 402 with code
|
||||
`file_too_long`.
|
||||
- A **pro subscription** is a `users.plan` + `plan_expires_at` row
|
||||
(Alembic 0004). Expired subscribers fall back to the free limits
|
||||
automatically; renewals stack the remaining time on top.
|
||||
- Operators grant subscriptions with `POST /admin/users/{email}/plan`
|
||||
authenticated by `X-Admin-Key` (constant-time comparison; the admin
|
||||
surface answers 503 unless `ADMIN_API_KEY` is configured). There is
|
||||
deliberately **no payment gateway** — plan changes are an operator
|
||||
decision, not a checkout.
|
||||
|
||||
Rejections are transparent, not silent: the dashboard and the bot
|
||||
surface the same 402 codes (the bot checks a voice's length against the
|
||||
caller's plan before upload and answers `/quota` with live numbers).
|
||||
|
||||
## Feature flags
|
||||
|
||||
|
||||
@@ -119,6 +119,10 @@
|
||||
<h3>ربات تلگرام و جداسازی گوینده</h3>
|
||||
<p>پیام صوتی بفرستید، متن را همانجا تحویل بگیرید؛ در صورت نیاز با برچسب گوینده از دو موتور دیاوریزیشن (هیوریستیک energy یا شبکهای pyannote).</p>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h3>سهمیهٔ شفاف، نه پیام خطای خاموش</h3>
|
||||
<p>پلن رایگان (فایل ۱۰ دقیقهای، ۳۰ دقیقه در ماه) و پلن حرفهای با متغیرهای محیطی قابل تنظیماند؛ عبور از سقف یعنی پاسخ صادقانهٔ HTTP 402 با کد <code>quota_exceeded</code> یا <code>file_too_long</code> — نه سکوت.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
Reference in new issue
Block a user