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:
process.env
/etc/ai-news-writer/secrets.env
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`.
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
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
Aligns
docs/SECRETS_MANAGEMENT.mdwith the actual precedence implemented insrc/config/secrets.jsand locks the contract with a stub-basedload()test, closing the documentation drift left over from #15 / BIT-4294.Why
SecretsManager.load()performs threeObject.assigncalls in this order so the last source wins:process.env/etc/ai-news-writer/secrets.env.envPR #15 fixed the merge-order comment inside
secrets.jsto match this, but the standalonedocs/SECRETS_MANAGEMENT.mdstill 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.envmust not exist on deployed hosts and howtools/deploy/lxc-secrets-inject.shenforces that, and clarify where built-in defaults live.src/config/secrets.test.js— add aload() — precedence (BIT-4294 contract)integration test that stubsfs.existsSync/fs.readFileSyncso the singleton'sload()itself runs against in-memory file contents. Asserts the override matrix end-to-end via bothload()andget().Verification
Runtime semantics are unchanged.
Issue
done.auto-approve: CI success (gitea_auto_approve_open_prs_once.py)
auto-approve: CI success (gitea_auto_approve_open_prs_once.py)
auto-approve: CI success (gitea_auto_approve_open_prs_once.py)
New commits pushed, approval review dismissed automatically according to repository settings
New commits pushed, approval review dismissed automatically according to repository settings
New commits pushed, approval review dismissed automatically according to repository settings