feat(ops): BIT-14770 + BIT-14772 deployment runbooks and DB/caching improvements #12

Merged
spark merged 13 commits from task/BIT-14770-deployment-runbooks into main 2026-05-01 20:46:07 +01:00
13 Commits
Author SHA1 Message Date
David Santos 616f8b0f52 fix(ci): do not fail Gitea Actions on artifact/Codecov steps
ai-news-writer-ci / test (pull_request) Successful in 44s
act_runner often cannot complete actions/upload-artifact@v3; treat upload and
Codecov as optional. Require coverage/lcov.info after tests so quality gate stays
strict. Harden PyYAML install for workflow parse step (PEP 668 / user site).
2026-05-01 20:43:34 +01:00
Patrícia Santos a24fdef09a fix(lint): comma-dangle in ai.js module.exports
ai-news-writer-ci / test (pull_request) Failing after 39s
2026-05-01 19:33:53 +00:00
Patrícia Santos 7daa716fb7 fix(writer): export OpenAI retry helpers for tests and consumers
ai-news-writer-ci / test (pull_request) Failing after 28s
2026-05-01 19:32:23 +00:00
Patrícia Santos 57ffe92833 fix(lint): comma-dangle and unused node:test imports (eslint --fix)
ai-news-writer-ci / test (pull_request) Failing after 35s
2026-05-01 19:12:17 +00:00
spark 113d0e56d4 Merge branch 'main' into task/BIT-14770-deployment-runbooks
ai-news-writer-ci / test (pull_request) Failing after 29s
2026-05-01 05:00:54 +01:00
David Santos 14f35d34dd fix(ci): apply ESLint-heal fileset from task/BIT-2983-test-coverage (BIT-15735)
ai-news-writer-ci / test (pull_request) Failing after 28s
2026-05-01 01:57:22 +01:00
Patrícia Santos eb6b99e2fe docs(obs): add observability foundation reference for BIT-14225
ai-news-writer-ci / test (pull_request) Failing after 0s
Documents the monitoring stack delivered by BIT-14225: structured
logging, Prometheus metrics, health/metrics HTTP endpoints, and webhook
alerting. All implementation files were committed in prior commits
(b095214, de9fff6, etc.); this adds the ops reference doc.

Paperclip-Task-Id: BIT-14225
Paperclip-Run-Id: $PAPERCLIP_RUN_ID
2026-04-28 19:31:38 +00:00
Patrícia SantosandPaperclip 38ebc60ad9 feat(security): BIT-5254 implement audit logging for secret access
- Add src/logger/audit.js: dedicated audit logger writing to logs/audit.log
  and logs/combined.log; events: secret.access, secret.missing,
  secrets.loaded, auth.success, auth.failure; never logs secret values
- Integrate audit.logSecretAccess() and audit.logSecretsLoaded() into
  SecretsManager.get() and load() in src/config/secrets.js
- Integrate audit.logAuthAttempt() into adminOk() in src/http/ui-auth.js,
  distinguishing no_token / invalid_token / no_admin_token_configured
- Add audit_log() function to tools/deploy/lxc-secrets-inject.sh writing
  JSON events to syslog (security.info) and stderr for gitea.secret.fetched,
  gitea.secret.fetch_failed, lxc.injection.started, lxc.injection.completed
- Add src/logger/audit.test.js covering all exported functions (11 cases)
- All 341 tests pass

Co-Authored-By: Paperclip <[email protected]>
2026-04-28 00:39:46 +00:00
Patrícia SantosandPaperclip dde4398c8e fix(lint): BIT-14772 resolve ESLint errors in new modules
ai-news-writer-ci / test (pull_request) Failing after 30s
- Remove trailing commas (comma-dangle: never) from maintenance.js and
  schema.js SCHEMA_MIGRATIONS array
- Replace backtick strings without interpolation with single quotes
  (quotes: single) in maintenance.js and schema.js
- Replace while(true) with for(;;) in file-lock.js to satisfy
  no-constant-condition rule

Co-Authored-By: Paperclip <[email protected]>
2026-04-28 00:07:01 +00:00
Patrícia Santos ee774c6d37 feat(ops): BIT-14772 database and caching improvements
ai-news-writer-ci / test (pull_request) Failing after 30s
- Add DB_SCHEMA.md documenting article-index JSONL, all PostgreSQL
  analytics tables (engagement_events, article_analytics, daily_metrics,
  category_benchmarks), in-memory caches, and O(n) benchmark notes
- Add three missing composite indexes to analytics schema migrations
  (idx_engagement_captured_date, idx_article_published_date,
  idx_daily_metrics_post_date)
- Add src/analytics/maintenance.js: daily retention purge for all
  analytics tables plus VACUUM ANALYZE; configurable via env vars
- Add src/store/file-lock.js: POSIX O_CREAT|O_EXCL advisory lock with
  stale-lock cleanup; prevents TOCTOU races on article-log writes
- Wire file-lock into article-log: appendArticleRecord and
  updateArticleMetadata (including slug uniqueness check) now run inside
  the lock, preventing duplicate-slug races between concurrent processes
- Add src/listener/guid-store.js: persistent GUID deduplication store
  with atomic save, 2000-GUID cap, and FIFO trim to 1500
- Wire guid-store into rss-listener: GUIDs now load from disk on startup
  and are saved atomically before on_new_articles fires, so listener
  deduplication survives process restarts
- Add tests: file-lock.test.js (6 cases), guid-store.test.js (10 cases);
  all 45 tests pass
- Add data/listener-guid-store.json and data/*.json to .gitignore
2026-04-27 22:55:59 +00:00
Patrícia Santos c4c44dc3ef docs(ops): add deployment and rollback runbooks for ai-news-writer
- Add docs/runbooks/DEPLOYMENT.md: day-to-day deploy pipeline overview,
  staging/prod promote flow, env configs, zero-downtime PM2 strategy,
  manual emergency deploy procedure
- Add docs/runbooks/ROLLBACK.md: decision tree (rollback vs hotfix),
  5 rollback procedures (RB-1 restart through RB-5 full wipe/redeploy),
  failure modes table, post-rollback checklist
- Update docs/runbooks/README.md: add Deploy & Rollback section linking
  both new runbooks

Closes BIT-14770
2026-04-27 22:51:56 +00:00
Patrícia Santos e868644f6f chore(deps): add npm audit CI gate and dependency update policy
ai-news-writer-ci / test (pull_request) Failing after 28s
- Add npm audit --audit-level=high step to test.yml CI workflow
- Create docs/dependency-update-policy.md with update cadence,
  security scanning procedure, and documented major-version holdbacks
  (openai 4→6, eslint 8→10, c8 9→11, dotenv 16→17)

Addresses BIT-14769 acceptance criteria:
  * Dependency scanning integrated into CI pipeline
  * Update policy documented in docs/
  * All packages >2 major versions behind have documented reasons

Paperclip-Issue: BIT-14769
Paperclip-Run: f8099c2b-26da-4c95-b001-a8b57a6d9f6f
2026-04-27 22:47:13 +00:00
Patrícia SantosandPaperclip 06bc5c5c4e fix(security): upgrade fast-xml-parser to v5 and node-cron to v4, apply npm audit fix
Resolves all 7 known vulnerabilities:
- fast-xml-parser ^4.5.1 → ^5.7.2 (GHSA-gh4j-gqv2-49f6: XMLBuilder comment/CDATA injection)
- node-cron ^3.0.3 → ^4.2.1 (GHSA-w5hq-g745-h8pq: uuid buffer bounds check)
- axios, follow-redirects, brace-expansion, picomatch fixed via npm audit fix

API compatibility verified: XMLParser options (ignoreAttributes, trimValues, parseTagValue)
unchanged in v5; cron.schedule() + task.stop() unchanged in v4.
251 tests pass.

Co-Authored-By: Paperclip <[email protected]>
2026-04-27 22:46:15 +00:00