docs(secrets): BIT-4294 — align SECRETS_MANAGEMENT precedence with secrets.js #17

Merged
spark merged 2 commits from task/BIT-4294-secrets-doc-precedence into main 2026-05-09 12:22:29 +01:00
Owner

Summary

Aligns docs/SECRETS_MANAGEMENT.md with the actual precedence implemented in src/config/secrets.js and locks the contract with a stub-based load() test, closing the documentation drift left over from #15 / BIT-4294.

Why

SecretsManager.load() performs three Object.assign calls in this order so the last source wins:

  1. process.env
  2. /etc/ai-news-writer/secrets.env
  3. repo .env

PR #15 fixed the merge-order comment inside secrets.js to match this, but the standalone docs/SECRETS_MANAGEMENT.md still claimed the inverse precedence (system file > .env > process.env). Operators reading the doc would expect deployed secrets to win over a stray repo .env; the runtime does the opposite. Worth calling out so deployment tooling and reviewers can rely on a single source of truth.

Changes

  • docs/SECRETS_MANAGEMENT.md — rewrite the load-order section to describe the real precedence (.env > /etc/ai-news-writer/secrets.env > process.env), add a production-safety note explaining why .env must not exist on deployed hosts and how tools/deploy/lxc-secrets-inject.sh enforces that, and clarify where built-in defaults live.
  • src/config/secrets.test.js — add a load() — precedence (BIT-4294 contract) integration test that stubs fs.existsSync/fs.readFileSync so the singleton's load() itself runs against in-memory file contents. Asserts the override matrix end-to-end via both load() and get().

Verification

node --test src/config/secrets.test.js
# 17 tests pass (including the new precedence test)

node --test src/config/*.test.js
# 50 tests pass — no regressions in loader / writing-style / listen-defaults / validator

Runtime semantics are unchanged.

Issue

  • Closes the doc-drift remainder of BIT-4294 (TDB-3 epic).
  • Unblocks BIT-4602 (TDB-3.2) once BIT-4294 moves to done.
## Summary Aligns `docs/SECRETS_MANAGEMENT.md` with the actual precedence implemented in `src/config/secrets.js` and locks the contract with a stub-based `load()` test, closing the documentation drift left over from #15 / BIT-4294. ## Why `SecretsManager.load()` performs three `Object.assign` calls in this order so the **last source wins**: 1. `process.env` 2. `/etc/ai-news-writer/secrets.env` 3. repo `.env` PR #15 fixed the merge-order comment inside `secrets.js` to match this, but the standalone `docs/SECRETS_MANAGEMENT.md` still claimed the inverse precedence (system file > .env > process.env). Operators reading the doc would expect deployed secrets to win over a stray repo `.env`; the runtime does the opposite. Worth calling out so deployment tooling and reviewers can rely on a single source of truth. ## Changes - `docs/SECRETS_MANAGEMENT.md` — rewrite the load-order section to describe the real precedence (`.env > /etc/ai-news-writer/secrets.env > process.env`), add a production-safety note explaining why `.env` must not exist on deployed hosts and how `tools/deploy/lxc-secrets-inject.sh` enforces that, and clarify where built-in defaults live. - `src/config/secrets.test.js` — add a `load() — precedence (BIT-4294 contract)` integration test that stubs `fs.existsSync`/`fs.readFileSync` so the singleton's `load()` itself runs against in-memory file contents. Asserts the override matrix end-to-end via both `load()` and `get()`. ## Verification ``` node --test src/config/secrets.test.js # 17 tests pass (including the new precedence test) node --test src/config/*.test.js # 50 tests pass — no regressions in loader / writing-style / listen-defaults / validator ``` Runtime semantics are unchanged. ## Issue - Closes the doc-drift remainder of [BIT-4294](/BIT/issues/BIT-4294) (TDB-3 epic). - Unblocks [BIT-4602](/BIT/issues/BIT-4602) (TDB-3.2) once BIT-4294 moves to `done`.
spark added 1 commit 2026-05-09 02:12:15 +01:00
docs(secrets): align SECRETS_MANAGEMENT precedence with secrets.js
ai-news-writer-ci / test (pull_request) Failing after 38s
50ed210353
PR #15 (commit 0ab7e7e) fixed the merge-order comment inside
src/config/secrets.js but the standalone docs/SECRETS_MANAGEMENT.md
still claimed the inverse precedence (system file > .env > process.env),
which contradicts the runtime where SecretsManager.load() applies
process.env then /etc/ai-news-writer/secrets.env then the repo .env so
the last assignment wins.

Changes:
- Update docs/SECRETS_MANAGEMENT.md to reflect the true precedence
  (.env > /etc/ai-news-writer/secrets.env > process.env) plus a
  production-safety note explaining why .env must not exist on
  deployed hosts and how lxc-secrets-inject.sh enforces that.
- Add a load() precedence test in src/config/secrets.test.js that
  stubs fs.existsSync/fs.readFileSync to exercise the singleton end
  to end, locking the contract so future refactors fail loudly if the
  merge order changes without a docs update.

Closes the documentation drift left over from BIT-4294 PR #15. The
runtime semantics are unchanged.

Paperclip-Agent: David Santos (id 0b1fcf92-5fe3-4ac0-9f29-df4ab72f5376)
Paperclip-Issue: BIT-4294
Paperclip-Run: d5bfe2e3-56d0-418f-a8fd-80817aaa40f2
paperclip-review-bot approved these changes 2026-05-09 02:32:23 +01:00
Dismissed
paperclip-review-bot left a comment
Member

auto-approve: CI success (gitea_auto_approve_open_prs_once.py)

auto-approve: CI success (gitea_auto_approve_open_prs_once.py)
founding-engineer approved these changes 2026-05-09 02:32:24 +01:00
Dismissed
founding-engineer left a comment
Member

auto-approve: CI success (gitea_auto_approve_open_prs_once.py)

auto-approve: CI success (gitea_auto_approve_open_prs_once.py)
devops-engineer approved these changes 2026-05-09 02:32:25 +01:00
Dismissed
devops-engineer left a comment
Member

auto-approve: CI success (gitea_auto_approve_open_prs_once.py)

auto-approve: CI success (gitea_auto_approve_open_prs_once.py)
spark scheduled this pull request to auto merge when all checks succeed 2026-05-09 02:32:26 +01:00
spark added 1 commit 2026-05-09 12:21:14 +01:00
chore(deps): fix npm audit high (fast-xml-builder)
ai-news-writer-ci / test (pull_request) Successful in 1m11s
c340d41f19
Resolves transitive advisory so `npm audit --audit-level=high` passes in
Gitea Actions; unblocks merge of PR #17 (secrets doc + precedence test).

Paperclip-Issue: BIT-4602
Paperclip-Run: 8225f565-2ac5-41fb-abb0-65b6ae6bf099
spark dismissed paperclip-review-bot's review 2026-05-09 12:21:14 +01:00
Reason:

New commits pushed, approval review dismissed automatically according to repository settings

spark dismissed founding-engineer's review 2026-05-09 12:21:14 +01:00
Reason:

New commits pushed, approval review dismissed automatically according to repository settings

spark dismissed devops-engineer's review 2026-05-09 12:21:14 +01:00
Reason:

New commits pushed, approval review dismissed automatically according to repository settings

spark merged commit cdee2843bd into main 2026-05-09 12:22:29 +01:00
Sign in to join this conversation.