Skip to content

Enforce OSL style with OSL's own lint rules - #76

Merged
Mistium merged 6 commits into
mainfrom
osl-lint-config
Nov 1, 2026
Merged

Mistium merged 6 commits into
mainfrom
osl-lint-config

Conversation

@Mistium

@Mistium Mistium commented Nov 1, 2026

Copy link
Copy Markdown
Member

Moves the API's OSL style checks onto OSL's own linter, now that OSL reads lint rules from opal.json (osl/.go#51).

What changes

  • CI pins OSL to 78deaec4. That's the previous pin 5895982f plus the lint config feature, so the compiler is otherwise unchanged.

  • opal.json gains a lint section with these severities:

    • errors: OSL-COMMENT and OSL-UNTYPED-GLOBAL;
    • warnings for a later pass: OSL-OBJECT-PARAM (581) and OSL-LONG-FUNCTION (53).
  • osl lsp check, osl test and osl compile fail on these errors.

  • Comments: every comment in the OSL code is removed, 531 lines across 56 files. Where a comment explained a number, the number is now a named constant with the same value:

    • roturPaymentRequestLifetimeMs and paymentRequestReuseMarginMs;
    • unpaidPurchaseKeyLifetimeMs and paidPurchaseKeyLifetimeMs;
    • roturReportFilingGraceMs;
    • roturRequestTimeoutSeconds;
    • roturWebhookMaxClockSkewSeconds;
    • zipCentralDirectoryHeader.

    The design reasoning in the longer comments is in the backend docs (Document the storage ledger, history, webhooks and other backend design notes docs#22).

  • Typed globals: every top-level variable has a declared type: *cache.Cache, *db.DB, *s3.Client and the matching scalar types in tests.

    Four caches stay auto behind // osl-disable-next-line OSL-UNTYPED-GLOBAL: shared projects, bans, shadow bans and the development feed. These hold whole-collection snapshots that are read on ordinary requests. A typed *cache.Cache walks every value it returns to convert records, which would add about 0.4 ms per 1,000 projects to every explore request. The other caches hold scalars or small per-user objects.

  • scripts/check_conventions.py:

    • no longer checks comments in .osl files, since the linter does that now;
    • still checks comments in Go and Python, and em dashes in every file type, OSL included;
    • newly rejects added osl-disable-* directives that name no codes or that turn off OSL-COMMENT, so the linter's comment rule can't be switched off quietly.
  • AGENTS.md describes how the checks are now split.

No runtime behaviour or /v1 response changes.

Verification

Run with OSL 78deaec4:

  • python3 scripts/check_conventions.py --base=origin/main: passes, and catches a planted em dash in .osl, a Go comment and each forbidden directive form.
  • osl lsp check main.osl: passes, with warnings only.
  • osl test: 60 passed, 0 failed.
  • osl compile main.osl: builds for both this branch and main.
  • scripts/e2e_smoke.py <main binary> <branch binary>: 328 steps with no server errors, and every response is the same on both binaries ("responses match").
  • The generated Go was compared for both branches: the only differences are the typed cache reads and one HTTP timeout literal (10 to 10.0).

An independent review found nothing that must be fixed. Both should-fix findings are dealt with here: the snapshot cache cost, and the reasoning that lived only in comments, which is now in the docs.

No visible surface: lint config, CI pin, comments and types only.

Deploying

Production should now be compiled with an OSL 78deaec4 build instead of osl-5895, so the deploy matches CI. The older build ignores the lint key, so it would still work.

@Mistium
Mistium merged commit af1616c into main Nov 1, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant