Skip to content

Commit 2aeb213

Browse files
authored
Merge pull request #14 from podverse/feature/app-gating
Feature/app gating
2 parents 90af21a + f659d04 commit 2aeb213

226 files changed

Lines changed: 8657 additions & 912 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.cursor/skills/api-testing/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Use this skill when adding or changing auth endpoints, versioned routes, or any
5050
## Quick reference
5151

5252
- **Default execution strategy (agent/sandbox):** start with the leanest targeted integration test command that verifies the change (for example a single test file), then expand scope only if needed.
53-
- Run tests: `npm run test` from repo root (or `./scripts/nix/with-env npm run test` in Nix/agent). First step is the requirements check, then Vitest runs for `apps/api` and `apps/management-api` (globalSetup then test files), then for `metaboost-signing` and `@metaboost/rss-parser`.
53+
- Run tests: `npm run test:e2e:api` from repo root for API integration tests only (or `./scripts/nix/with-env npm run test:e2e:api` in Nix/agent). First step is the requirements check, then Vitest runs for `apps/api` and `apps/management-api`. For unit-only (no DB needed): `npm run test:unit`. Full suite: `npm test`.
5454
- Run one API integration test file (preferred during iteration): `./scripts/nix/with-env npm run test -w apps/api -- src/test/<file>.test.ts`
5555
- Test env: `apps/api/src/test/setup.ts` sets defaults (DB_PORT 5632, VALKEY_PORT 6579, DB_APP_NAME metaboost_app_test, etc.). globalSetup uses the same defaults so it can run without setupFiles.
5656
- Mailer in tests: No real SMTP. `auth-mailer.test.ts` sets `MAILER_ENABLED=true` and mocks `../lib/mailer/send.js` to capture tokens for verify-email, reset-password, and confirm-email-change.

.cursor/skills/global/SKILL.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ version: 1.1.1
1515
## TypeScript
1616

1717
- Extend `tsconfig.base.json` in apps. Use ESM (NodeNext). Avoid type assertions (`as`) when a better approach exists.
18+
- Prefer **named exports**; avoid `export default` in ordinary modules when a named export works. See **.cursor/skills/prefer-named-exports/SKILL.md** (Next.js `page` defaults excepted).
1819

1920
## Plan Management
2021

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
name: prefer-named-exports
3+
description: >-
4+
Prefer named exports in TypeScript/ESM modules; avoid default exports when a named export
5+
is sufficient. Use in Metaboost and Podverse when adding or editing modules, API routes, worker
6+
commands, packages, and app code. Framework-required defaults are the exception.
7+
version: 1.0.0
8+
---
9+
10+
# Prefer named exports
11+
12+
## When to use
13+
14+
- Creating or changing `.ts` / `.tsx` modules, `packages/*`, and app code in this monorepo.
15+
- Refactoring imports; choosing export style for a new function, component, or command.
16+
17+
## Rules
18+
19+
- **Prefer** `export function name`, `export const name`, and `export type` / `export { x }` so names stay stable at import sites and refactors are easier to trace.
20+
- **Avoid** `export default` for ordinary modules when there is a single main export: use a **named** export with a clear, stable name.
21+
22+
## Exceptions (defaults are fine)
23+
24+
- **Next.js (App Router)**: `page.tsx`, `layout.tsx`, and similar files that the framework **requires** as the default export.
25+
- **Stricter framework contracts**: e.g. Storybook or tooling that only accepts `export default` (prefer named exports in the same file for everything else, or a thin default wrapper that re-exports a named symbol).
26+
- **Generated or third-party patterns**: match the existing file’s style when the file is not yours to own.
27+
28+
## Imports
29+
30+
- Use `import { foo } from './bar.js'`, not `import foo from './bar.js'`, for named exports.
31+
- Re-exporting: `export { foo } from './bar.js'` in barrels instead of re-exporting a default with an alias, when possible.
32+
33+
## Related
34+
35+
- ESM: `.js` extension in import paths (see repo `tsconfig` / `.cursorrules` stack notes). The Podverse monorepo has the same skill for cross-repo consistency.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
name: release-changelog
3+
description: "Keep the upcoming release note buffer updated on develop; ties into publish workflows (alpha → staging.N, beta → beta.N, main → RTM) and GitHub release/archive automation."
4+
---
5+
6+
# Release changelog (Metaboost)
7+
8+
## When to use
9+
10+
When you ship or finish work that is **worth calling out** in preprod/prod release notes: behavior changes, new surfaces, important fixes, or ops-impacting updates—not every internal cleanup.
11+
12+
## What to update
13+
14+
- Edit [docs/operations/CHANGELOG-UPCOMING.md](../../docs/operations/CHANGELOG-UPCOMING.md) on **`develop` only** (promotion branches are triggers only—see [PUBLISH.md](../../PUBLISH.md)).
15+
16+
## Conventions
17+
18+
1. **Order****Most important first** (safety, security, data, then big features, then smaller fixes; skip low-signal items).
19+
2. **Wording** — Short, clear lines; link issues/PRs if useful.
20+
3. **Markers** — Put new bullets between `UPCOMING-AUTO-START` and `UPCOMING-AUTO-END` so post-publish automation can reset that block via PR. Notes **above** the block are not auto-cleared.
21+
4. **Brevity** — Concise, not a duplicate of git log.
22+
23+
## Naming in CI
24+
25+
- Git branch **`alpha`** still produces **`X.Y.Z-staging.N`** and float **`staging`** in GHCR (cluster “alpha” in GitOps is separate). Branch **`beta`**`-beta.N` and `:beta`. Branch **`main`** → RTM **`X.Y.Z`** and `:prod`.
26+
27+
## Related
28+
29+
- [PUBLISH.md](../../PUBLISH.md) — full publish flow, Git tag, and GitOps pins.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
name: unit-tests-confident-granularity
3+
description: Enforces Metaboost unit-test scope at a confident-not-bulletproof level. Use when writing unit tests to avoid both under-testing and excessive combinatorial test complexity.
4+
version: 1.0.0
5+
---
6+
7+
# Unit Tests - Confident Granularity
8+
9+
## Goal
10+
11+
Deliver strong confidence without turning test suites into unmaintainable exhaustive matrices.
12+
13+
## Confident Coverage Rule
14+
15+
For each critical module under test, include:
16+
17+
1. Happy path behavior.
18+
2. Guard/rejection behavior for invalid input or state.
19+
3. Boundary behavior (limits, edge values, time windows).
20+
4. Safe-failure behavior (no privileged fallback).
21+
22+
## Stop Conditions (Avoid Over-Testing)
23+
24+
Do not keep adding unit tests once all are true:
25+
26+
- Every meaningful branch has at least one direct assertion.
27+
- At least one representative negative case exists for each guard.
28+
- Additional cases only duplicate already-proven behavior.
29+
30+
## What To Avoid
31+
32+
- Exhaustive Cartesian permutations that do not add new behavior confidence.
33+
- Snapshot-heavy tests for business logic.
34+
- Tests that lock internal implementation details instead of module contract.
35+
36+
## Permutation Sampling Guidance
37+
38+
When a matrix is large, use representative rows:
39+
40+
- One allow example per permission source (owner, admin, etc.).
41+
- One deny example per missing permission path.
42+
- One edge case for malformed/missing data.
43+
44+
Add more rows only when they validate a different branch.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
name: unit-tests-risk-first
3+
description: Prioritizes unit tests by risk and regression impact in Metaboost. Use when adding or expanding unit tests so coverage is focused on auth, authorization, security boundaries, and high-reuse helpers before lower-risk code.
4+
version: 1.0.0
5+
---
6+
7+
# Unit Tests - Risk First
8+
9+
## Use This Skill When
10+
11+
- Creating a new unit-test backlog.
12+
- Expanding coverage in a large area and deciding what to test first.
13+
- Choosing between multiple candidate modules for limited time.
14+
15+
## Priority Order
16+
17+
1. **Auth and identity boundaries**
18+
- JWT claim handling, assertion verification, session/cookie safety.
19+
2. **Authorization decisions**
20+
- Permission and role checks, allow/deny branching.
21+
3. **Security-sensitive transforms**
22+
- Token hashing/expiry logic, request binding checks, serialization guards.
23+
4. **High-reuse helper logic**
24+
- Shared helper functions used by multiple apps/packages.
25+
5. **UI utility logic**
26+
- Frontend policy helpers that gate user actions.
27+
28+
## Selection Rule
29+
30+
When choosing the next test target, prefer modules with:
31+
32+
- Higher blast radius (many callers or privileged code path).
33+
- Higher probability of silent failure (wrong allow/deny outcome).
34+
- Higher user/security impact if behavior drifts.
35+
36+
Skip low-risk wrappers until higher-risk targets have coverage.
37+
38+
## Required Output Shape
39+
40+
When proposing or implementing tests, include:
41+
42+
- Why this target is high-priority.
43+
- Which behavior branches are being covered.
44+
- Which lower-priority targets are intentionally deferred.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
name: unit-tests-security-authz-template
3+
description: Provides a repeatable case template for auth, permission, and security-sensitive unit tests in Metaboost. Use when testing JWT, assertion validation, cookie/session helpers, bucket policy, or similar allow/deny logic.
4+
version: 1.0.0
5+
---
6+
7+
# Unit Tests - Security/Authz Template
8+
9+
## Use This Skill When
10+
11+
- Testing auth token helpers and claim validation.
12+
- Testing permission policy (bucket/admin/role/message CRUD decisions).
13+
- Testing security-sensitive request binding and replay controls.
14+
15+
## Standard Case Template
16+
17+
For each function/module, cover these case buckets:
18+
19+
1. **Accept valid input**
20+
- Confirm expected allow/success behavior.
21+
2. **Reject invalid input**
22+
- Missing/empty/malformed token, claim, id, or mask.
23+
3. **Enforce boundary rule**
24+
- Time window, max TTL, min/max limits, bitmask edge.
25+
4. **Enforce deny precedence**
26+
- Non-owner/non-admin or missing permission bit remains denied.
27+
5. **Preserve safe failure**
28+
- Errors return non-privileged result (`null`, `false`, or explicit reject response).
29+
30+
## Assertions Checklist
31+
32+
- Assert on outcome and error code/message contract where relevant.
33+
- Verify no accidental allow behavior in negative paths.
34+
- Keep fixtures minimal and explicit.
35+
- Mock only unstable boundaries (network, time, cache, external services).
36+
37+
## Matrix Update Rule
38+
39+
When introducing a new auth/authz/security module:
40+
41+
1. Add the module to the active test target matrix plan.
42+
2. Add at least one test from each relevant case bucket above.
43+
3. Record any intentionally deferred cases and why they are lower priority.

.cursorrules

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- No `any` types
1010
- **Strict equality**: Use `===` and `!==` only (no `==` or `!=`).
1111
- **Avoid type assertions (`as`)**: Prefer proper types, optional chaining, type guards, or narrowing.
12+
- **Named exports**: Prefer named `export` in TypeScript modules; avoid `export default` when a named export works. Framework-required defaults (e.g. Next.js `page.tsx`) are the exception. See `.cursor/skills/prefer-named-exports/SKILL.md`.
1213

1314
## Formatting
1415

0 commit comments

Comments
 (0)