Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .claude/rules/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ state-changing requests must also pass the double-submit CSRF check (see Securit
| POST | `/logout` | Blacklist current token (CSRF-checked) |
| POST | `/logout-all` | Revoke every token issued to this candidate up to now |
| POST | `/refresh` | Rotate tokens; blacklist old refresh token (CSRF-checked); reuse of a rotated token > 10s later revokes all sessions |
| POST | `/forgot-password` | Request password reset (stub — logged, not emailed) |
| POST | `/forgot-password` | Request password reset (link emailed via SMTP, `services/mail.ts`) |
| POST | `/reset-password` | Reset password using a reset token |
| GET | `/verify-email` | Verify email using a token issued on register (stub) |
| GET | `/verify-email` | Verify email using the token emailed on register |

`api/v2/auth` mirrors `/register` and `/login` only — still WIP.

Expand Down Expand Up @@ -86,8 +86,8 @@ best-effort — each item validated/created independently via the same
## Auth flow

1. `POST /auth/register` → validate Joi → check duplicate email → bcrypt(password, 12) → create Candidate doc
2. `POST /auth/login` → find by email → bcryptCompare → sign `accessToken` (TOKEN_SECRET) + `refreshToken` (TOKEN_REFRESH) with payload `{ _id: candidateId }` → set as httpOnly cookies (`utils/authCookies.ts`) and returned in the response body
2. `POST /auth/login` → find by email → bcryptCompare → sign `accessToken` (TOKEN_SECRET) + `refreshToken` (TOKEN_REFRESH) with payload `{ _id: candidateId, jti }` (random `jti` per token, so two signed in the same second never collide) → set as httpOnly cookies (`utils/authCookies.ts`) and returned in the response body
3. All protected requests → `verifyToken` middleware → extract token (Bearer header, cookie, body, or query via `extractTokenWithSource`) → `jwtVerify` → check blacklist → check per-candidate session-revocation timestamp (`sessionRevocation.ts`) → if the request authenticated purely off the cookie, require a valid double-submit CSRF token → attach `req.user._id` and force `req.body.candidateId` to it
4. `POST /auth/refresh` → CSRF-checked → if the token was already rotated away: 403, and if that rotation was more than 10s ago (not a concurrent refresh) treat it as theft → `invalidateAllSessions` (once — a token already predating the last revocation doesn't re-trigger it) → otherwise verify refresh token → blacklist old refresh token with a rotated-at marker → issue new pair (refresh tokens carry a random `jti` so two issued in the same second never collide)
4. `POST /auth/refresh` → CSRF-checked → if the token was already rotated away: 403, and if that rotation was more than 10s ago (not a concurrent refresh) treat it as theft → `invalidateAllSessions` (once — a token already predating the last revocation doesn't re-trigger it) → otherwise verify refresh token → blacklist old refresh token with a rotated-at marker → issue new pair (both carry a fresh random `jti`)
5. `POST /auth/logout` → CSRF-checked → add token to blacklist (Redis TTL = token remaining exp; mem fallback)
6. `POST /auth/logout-all` → bump the candidate's session-invalidated-at timestamp so every token issued before now is rejected on next use, even if not individually blacklisted or expired
2 changes: 1 addition & 1 deletion .claude/skills/browser-debugger/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: browser-debugger
description: "Open a browser (Chrome/Firefox/Edge) with remote-debugging port 9888 so Claude can inspect/control it — optionally starting `npm run dev` first and pointing the browser at it. Usage: /browser-debugger [--browser=chrome|firefox|edge] [--run-dev]. Read-only dev utility, no code changes, no seal gate."
description: "Open a browser (Chrome/Firefox/Edge) with remote-debugging port 9888 so Claude can inspect/control it — optionally starting `npm run dev` first and pointing the browser at it. Usage: /browser-debugger [--browser=chrome|firefox|edge] [--run-dev]. Read-only dev utility, no code changes, no seal gate. Use when Claude needs to inspect or drive a live browser page."
argument-hint: "[--browser=chrome|firefox|edge] [--run-dev]"
---

Expand Down
11 changes: 6 additions & 5 deletions .claude/skills/hub-health/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ echo "FLAGS:"
DIAG_FILE="$HUB/haven/diagrams/dev-loop.prime-mermaid.md"
if [ -f "$DIAG_FILE" ]; then
DB=$(wc -c < "$DIAG_FILE")
FULL_SEALED=$(grep -cE '\| SEALED \|' "$DIAG_FILE" 2>/dev/null)
POINTER_SEALED=$(grep -cE '— archived, see' "$DIAG_FILE" 2>/dev/null)
FULL_SEALED=$(grep -cE '^\| .*\| SEALED \|' "$DIAG_FILE" 2>/dev/null)
POINTER_SEALED=$(grep -cE '^\| .*— archived, see' "$DIAG_FILE" 2>/dev/null)
REAL_SEALED=$(( FULL_SEALED - POINTER_SEALED ))
check_threshold_bytes "dev-loop.prime-mermaid.md" "$DB" 15360 \
"$REAL_SEALED full SEALED entries not yet archived ($POINTER_SEALED pointers; verify_seal step 11 should keep these at 0 full / <=20 pointers — a backlog here predates that rule or means step 11 was skipped), see rows below"
Expand Down Expand Up @@ -213,7 +213,7 @@ def add(key, path):
k = (inp.get("file_path"), inp.get("offset"), inp.get("limit"))
reads.setdefault(k, []).append(size)
if name == "Bash" and err:
k = " ".join(str(inp.get("command", "")).split())[:120]
k = " ".join(str(inp.get("command", "")).split()) # full command: a long shared prefix (S=<scratchpad>…) isn't "the same command"
fails[k] = fails.get(k, 0) + 1
if size > 40000:
big.append((size, key, name, str(inp.get("file_path") or inp.get("command") or inp.get("description") or "")[:90]))
Expand Down Expand Up @@ -253,7 +253,7 @@ for fp, (n, ch) in top:
print(f" {n:>4}x {'image' if not ch else f'~{ch // 4} tok':>12} {fp}")
print(f" failing Bash command repeated >=3x in one run: {len(loops)}")
for cmd, n in sorted(loops.items(), key=lambda x: -x[1])[:5]:
print(f" {n:>4}x {cmd}")
print(f" {n:>4}x {cmd[:120]}")
print(f" tool results >40k chars (~10k tok): {len(big)}")
for size, who, name, what in sorted(big, reverse=True)[:5]:
print(f" ~{size // 4:>7} tok {who:15} {name}: {what}")
Expand Down Expand Up @@ -319,7 +319,8 @@ PY
`<path>/improvements/report/<YYYY-MM-DD>-#<NN>-hub-health-<project>.md`
— `<NN>` and the filename follow that repo's
`.claude/rules/improvements-naming.md` (read it first; next number
= highest `#` among `report/` filenames + 1, 2 digits). Sections:
per its rule, including its number floor — `report/` may be empty or
missing, create it). Sections:
`- **Recorded:**`, `- **Context:**` (project, kit version from
`agent-hub/.kit-version`, window), `- **Status:** unverified`,
`## Baseline` (output verbatim), `## Findings` (numbered: what,
Expand Down
2 changes: 1 addition & 1 deletion .claude/skills/issue-create/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: issue-create
description: "Create a GitHub issue in this repo. Drafts title/body, shows the exact gh command, waits for approval before creating."
description: "Create a GitHub issue in this repo. Drafts title/body, shows the exact gh command, waits for approval before creating. Use when the user wants a new issue filed."
argument-hint: "\"<what the issue is about>\" [--label x] [--assignee @me] [--yes]"
disable-model-invocation: true
---
Expand Down
2 changes: 1 addition & 1 deletion .claude/skills/issues-ls/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: issues-ls
description: "List open GitHub issues for this repo, if it's hosted on GitHub. Read-only, no side effects."
description: "List open GitHub issues for this repo, if it's hosted on GitHub. Read-only, no side effects. Use when picking the next task or reviewing the backlog."
argument-hint: "[--group] [--state open|closed|all] [gh issue list flags...]"
---

Expand Down
2 changes: 1 addition & 1 deletion .claude/skills/persona-load/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: persona-load
description: "Load an on-demand expert-persona or a named panel from this project's own persona library (outside agent-hub/), printing the loader's SEALED output for the current worker session to read. Advisory only, read-only, no side effects."
description: "Load an on-demand expert-persona or a named panel from this project's own persona library (outside agent-hub/), printing the loader's SEALED output for the current worker session to read. Advisory only, read-only, no side effects. Use when a worker needs domain-expert guidance for the current task."
argument-hint: "<category>/<name> | -p <panel> | -l [category]"
---

Expand Down
2 changes: 1 addition & 1 deletion .claude/skills/release/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: release
description: "Promote staging into main by running the bundled release.sh: build/test gate, real merge commit (no squash), semver bump + tag vX.Y.Z, deploy via DEPLOY_HOOK_URL or report the deploy workflow run, sync the bump back to staging, close shipped issues (Closes #n in the release PR, read from the merged PRs). Usage: /release [patch|minor|major]. Invoking this skill IS the operator's go-ahead — no separate confirmation prompt."
description: "Promote staging into main by running the bundled release.sh: build/test gate, real merge commit (no squash), semver bump + tag vX.Y.Z, deploy via DEPLOY_HOOK_URL or report the deploy workflow run, sync the bump back to staging, close shipped issues (Closes #n in the release PR, read from the merged PRs). Usage: /release [patch|minor|major]. Invoking this skill IS the operator's go-ahead — no separate confirmation prompt. Use when staging is ready to go to production."
argument-hint: "[patch|minor|major]"
disable-model-invocation: true
---
Expand Down
2 changes: 1 addition & 1 deletion .claude/skills/ship/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: ship
description: "Commit + push a SEALED node via the bundled ship.sh — the outward-facing gate at the end of the loop. Usage: /ship \"[note]\" or /ship \"[note]\" --merge[=branch] to also merge into a target branch (directly, or through a GitHub PR + required CI when ship.env sets SHIP_MERGE_VIA=pr). Prints the exact git commands, then runs them at once — invoking /ship is the approval. Never --force/--no-verify."
description: "Commit + push a SEALED node via the bundled ship.sh — the outward-facing gate at the end of the loop. Usage: /ship \"[note]\" or /ship \"[note]\" --merge[=branch] to also merge into a target branch (directly, or through a GitHub PR + required CI when ship.env sets SHIP_MERGE_VIA=pr). Prints the exact git commands, then runs them at once — invoking /ship is the approval. Never --force/--no-verify. Use when a node is SEALED and the work should be committed."
argument-hint: "[note] [--merge[=<branch>]]"
---

Expand Down
2 changes: 1 addition & 1 deletion .claude/skills/spec-backfill/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: spec-backfill
description: "Bulk-backfill draft feature docs (doctrine/features/) for features that already exist in the code. Writes only agent-hub docs, never code. Docs stay draft until confirmed via /worker analyst."
description: "Bulk-backfill draft feature docs (doctrine/features/) for features that already exist in the code. Writes only agent-hub docs, never code. Docs stay draft until confirmed via /worker analyst. Use when adopting agent-hub in a codebase whose existing features have no docs."
argument-hint: "[<area or path to limit the scan>]"
---

Expand Down
2 changes: 1 addition & 1 deletion .claude/skills/todo/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: todo
description: "Resolve/create a GitHub issue + check out that issue's own branch, then combine /worker analyst (feature, or a bug with no feature doc yet), /worker implementer and /worker verifier into 1 typed command for a task — still runs 2 separate passes inside, looping automatically on REOPEN. Usage: /todo \"[task]\"|#[issue-number] [--ship]"
description: "Resolve/create a GitHub issue + check out that issue's own branch, then combine /worker analyst (feature, or a bug with no feature doc yet), /worker implementer and /worker verifier into 1 typed command for a task — still runs 2 separate passes inside, looping automatically on REOPEN. Usage: /todo \"[task]\"|#[issue-number] [--ship] Use when running any feat or fix task end-to-end."
argument-hint: "<task>|#<issue-number> [--ship]"
disable-model-invocation: true
---
Expand Down
8 changes: 7 additions & 1 deletion .claude/skills/worker/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: worker
description: "Become an agent-hub worker (analyst, implementer or verifier) and carry out one task following exactly that worker's recipe. Usage: /worker [analyst|implementer|verifier] \"[task]\""
description: "Become an agent-hub worker (analyst, implementer or verifier) and carry out one task following exactly that worker's recipe. Usage: /worker [analyst|implementer|verifier] \"[task]\" Use when running one loop role by hand instead of /todo."
argument-hint: <analyst|implementer|verifier> "<task>"
---

Expand Down Expand Up @@ -53,6 +53,12 @@ argument-hint: <analyst|implementer|verifier> "<task>"
`recipes/verify_seal.md` step 1b makes the verifier record its own
spawn proof in the `## Isolation proof` line of the verdict note, so
a later audit can detect a skipped context split. (kit 2026-11-07)
Spawn it with `model: "sonnet"` (it checks cited evidence against
criteria, doesn't design). The spawn prompt names the absolute hub
path, the note path(s) and node slug(s) — never make the subagent
`ls` around to find its inputs, and never add re-run instructions
("re-run the checks yourself") — `verify_seal.md`'s "Re-run scope"
alone decides. (kit 2026-11-18)
Only exception to a fresh spawn: `/todo`'s REOPEN rounds resume the
same verifier subagent (`todo` step 3) — still never the
implementer's context.
Expand Down
11 changes: 11 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,14 @@ TOKEN_EXP_IN=7d
# caller's origin; unset in production blocks every cross-origin request.
CORS_ORIGIN=https://your-frontend-domain.example


# Email (password reset + email verification links), Nodemailer over SMTP.
# SMTP_HOST or APP_URL unset: development logs the link instead of sending;
# production logs a warning and sends nothing. SMTP_PORT 465 = implicit TLS.
SMTP_HOST=
SMTP_PORT=587
SMTP_USER=
SMTP_PASS=
MAIL_FROM=
# Frontend base URL the emailed links open (/reset-password, /verify-email)
APP_URL=
8 changes: 7 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,18 @@ CORS_ORIGIN=... # comma-separated allow-list; required for the http
TOKEN_REFRESH_EXP_IN=7d # optional; refresh token lifetime (default 7d)
TRUST_PROXY_HOPS=1 # optional; proxy hops in front of the app (1 on Render) so req.ip / rate limit
# key on the real client; unset = trust none (no proxy)
SMTP_HOST=... # optional; reset/verify links emailed via Nodemailer (services/mail.ts)
SMTP_PORT=587 # optional; 465 = implicit TLS
SMTP_USER=... / SMTP_PASS=...
MAIL_FROM=... # From address
APP_URL=... # frontend base URL for the emailed links; SMTP_HOST or APP_URL unset →
# dev logs the link, prod warns and sends nothing (never logs the token)
```

## Conventions

- Always import via the `@/` alias (`@/utils/helper`) — `src/*` in dev (tsconfig-paths), `dist/*` in prod (module-alias, `src/alias.ts`).
- Middleware order is `runServer` in `src/server.ts`. `/health` and `/api-docs` are registered before the rate limiter on purpose (exempt).
- Middleware order is `createApp` in `src/server.ts`. `/health` and `/api-docs` are registered before the rate limiter on purpose (exempt).
- New CV section → `src/candidate_profile/<section>/` controller + service + validate, built on `createCrudService()` (`BaseService.ts`) and `BaseController.ts`, like the existing sections.
- CV-section models + `Application` + `Profile` soft-delete via nullable `deletedAt` (`Visit` doesn't). Localized free-text fields use `localizedTextSchema` (`{ vi, en }`), resolved per request by `?lang=`.
- Errors: services throw `AppError` subclasses (`src/errors/`), never return `{ success:false }`. Every status comes from the `ERROR_STATUS` map in `errors/AppError.ts`; `withTimeout` throws `SERVICE_UNAVAILABLE` (503) on a DB/Redis timeout.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ REST API (Node.js + TypeScript) for managing candidate profiles (CVs): JWT login

## Features

- **Authentication** — JWT access/refresh (httpOnly cookie or Bearer), bcrypt, CSRF, token blacklist, log out of every device, refresh-token reuse detection, forgot/reset password (stub, no real email sent yet)
- **Authentication** — JWT access/refresh (httpOnly cookie or Bearer), bcrypt, CSRF, token blacklist, log out of every device, refresh-token reuse detection, forgot/reset password and email verification (links emailed over SMTP)
- **CV profile** — candidate information, education, experience (with career breaks), projects, awards, certificates, references; soft delete and restore
- **Multiple CV versions** — each version is a subset of the entries, with its own public link and PDF
- **Public profile** — custom slug, public profile search, view statistics (country, traffic source, CV version)
Expand Down
2 changes: 1 addition & 1 deletion agent-hub/.kit-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
af32868
e900251
3 changes: 3 additions & 0 deletions agent-hub/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ its content/diff into the session, even the first time a file is
created. Just report one line "📝 agent-hub: updated" and move on; report
done when finished. Real diffs/code (outside `agent-hub/`) still display
normally — that's what the operator actually needs to see.
Every tool call re-sends the whole context: batch independent read-only
lookups (greps, file reads, `ls`) into ONE Bash call instead of one call
each.

## Master Equation
**Aligned = Purpose × Evidence × Care** — a multiplication, not an
Expand Down
2 changes: 1 addition & 1 deletion agent-hub/doctrine/domains/PROJECT.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Repo: `github.com/datvt243/resume-nodejs-api`. Author: DatVT.
`npm run build`.

## Branch naming
Branch naming: `<type>/<issue-number>-<desc-max-3-words>` — type = `feature`/`fix`/`hotfix`/`refactor`/`perf`/`chore`, desc = at most 3 kebab-case words (e.g. `fix/408-general-info-confirm`). Changed 2026-11-16 from `<number>-<slug>` (operator request). Pick type from the issue: label `bug` → `fix` (`hotfix` if it must skip the normal release cadence), `enhancement`/`feature` → `feature`, else the title's leading verb (refactor/perf/chore…); unclear → ask.
Branch naming: `<type>/<issue-number>-<desc-max-3-words>` — type = `feature`/`fix`/`hotfix`/`refactor`/`perf`/`chore`, desc = at most 3 kebab-case words (e.g. `fix/408-general-info-confirm`); kept over kit default). Changed 2026-11-16 from `<number>-<slug>` (operator request). Pick type from the issue: label `bug` → `fix` (`hotfix` if it must skip the normal release cadence), `enhancement`/`feature` → `feature`, else the title's leading verb (refactor/perf/chore…); unclear → ask.

## Diagram-first
The diagram (`haven/diagrams/`) is the source of truth for progress — code
Expand Down
Loading
Loading