feat(config): align sources example, env docs, and secrets precedence notes
ai-news-writer-ci / test (pull_request) Successful in 1m27s
ai-news-writer-ci / test (pull_request) Successful in 1m27s
- Add config/sources.example.json for new installs; document in ops README - Extend .env.example with WP_CATEGORY, QUEUE_MAX_DEPTH, and optional analytics/pipeline/writing-style vars - Fix secrets.js merge-order comment to match implementation - Validate sources.domain_filter_mode (strict|warn|log) at startup - Fix status-server test cleanup var HTTP_BODY_READ_TIMEOUT_MS - Replace nonexistent OPENAI_TIMEOUT_MS hint in incident runbook Paperclip-Agent: David Santos (id 0b1fcf92-5fe3-4ac0-9f29-df4ab72f5376) Paperclip-Issue: BIT-4294 Paperclip-Run: bc46f5b4-65d4-462a-8b56-e991c4aca0c1
This commit is contained in:
1 parent
49cc061162
commit
0ab7e7ef1d
8 files changed
+86
-10
No files matched your search
@@ -13,6 +13,8 @@ ANTHROPIC_API_KEY=
|
||||
WP_URL=https://wp.newsproject.bitreport.pt
|
||||
WP_USER=
|
||||
WP_PASSWORD=
|
||||
# Default category ID when using env-only site config (no config/sites/*.json)
|
||||
WP_CATEGORY=1
|
||||
# rest (default) | xmlrpc — per-site override: wp_transport in config/sites/*.json
|
||||
WP_TRANSPORT=rest
|
||||
|
||||
@@ -71,6 +73,32 @@ ARTICLE_LOG_TRIM_AT_BYTES=2097152
|
||||
# Optional: only publish to WordPress as "publish" during these local hours [start, end) in CRON_TIMEZONE; outside → draft.
|
||||
# PUBLISH_HOURS=8-20
|
||||
|
||||
# Pipeline — max articles processed concurrently in listen/auto (memory + API pressure)
|
||||
QUEUE_MAX_DEPTH=5
|
||||
|
||||
# Optional: persist RSS GUID dedupe store elsewhere (default: under data/)
|
||||
# GUID_STORE_PATH=
|
||||
|
||||
# Monitoring — optional webhook when pipeline stages fail (Slack-compatible JSON)
|
||||
# PIPELINE_ALERT_WEBHOOK_URL=
|
||||
# PIPELINE_ALERT_WEBHOOK_TIMEOUT_MS=4000
|
||||
|
||||
# Writing style — optional overrides (defaults come from config/writing-style.example.json)
|
||||
# WRITING_STYLE_CONFIG_PATH=
|
||||
# WRITING_TONE=
|
||||
# AUDIENCE_LEVEL=
|
||||
|
||||
# Analytics DB (optional — module loads only when used)
|
||||
# ANALYTICS_DB_HOST=localhost
|
||||
# ANALYTICS_DB_PORT=5432
|
||||
# ANALYTICS_DB_NAME=ai_news_analytics
|
||||
# ANALYTICS_DB_USER=postgres
|
||||
# ANALYTICS_DB_PASSWORD=
|
||||
# ANALYTICS_DB_POOL_SIZE=10
|
||||
# ANALYTICS_ENGAGEMENT_RETENTION_DAYS=
|
||||
# ANALYTICS_DAILY_METRICS_RETENTION_DAYS=
|
||||
# ANALYTICS_BENCHMARKS_RETENTION_DAYS=
|
||||
|
||||
# Quality Scoring (article validation and metrics)
|
||||
# Minimum quality score for auto-approval (0-100, higher = stricter)
|
||||
QUALITY_MIN_SCORE=60
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"rss": [
|
||||
{
|
||||
"name": "Example — BBC Technology",
|
||||
"url": "https://feeds.bbci.co.uk/news/technology/rss.xml",
|
||||
"category": "technology",
|
||||
"lang": "en"
|
||||
},
|
||||
{
|
||||
"name": "Example — Guardian World",
|
||||
"url": "https://www.theguardian.com/world/rss",
|
||||
"category": "general",
|
||||
"lang": "en"
|
||||
}
|
||||
],
|
||||
"keywords": ["example", "keyword-one", "keyword-two"],
|
||||
"trusted_domains": ["bbc.co.uk", "theguardian.com"],
|
||||
"domain_filter_mode": "strict"
|
||||
}
|
||||
@@ -244,7 +244,7 @@ pm2 logs ai-news-writer --grep "openai\|429\|timeout" --lines 50
|
||||
# - Contact OpenAI for higher rate limit
|
||||
|
||||
# If timeout:
|
||||
# - Increase timeout in .env: OPENAI_TIMEOUT_MS
|
||||
# - Increase backoff in .env: OPENAI_RETRY_BASE_MS (and optionally OPENAI_MAX_ATTEMPTS)
|
||||
# - Reduce prompt complexity
|
||||
```
|
||||
|
||||
|
||||
@@ -49,8 +49,8 @@ npm run wp:test
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `.env` | Secrets (OpenAI key, WP credentials, admin token) — never commit |
|
||||
| `config/sources.json` | RSS feed URLs |
|
||||
| `.env` | Secrets (OpenAI key, WP credentials, admin token) — never commit; see root `.env.example` |
|
||||
| `config/sources.json` | RSS feed URLs (copy from `config/sources.example.json` for new installs) |
|
||||
| `config/social.json` | X / Twitter queries |
|
||||
| `config/sites/` | WordPress targets |
|
||||
| `ecosystem.config.cjs` | PM2 app definition |
|
||||
|
||||
@@ -7,11 +7,10 @@ const audit = require('../logger/audit');
|
||||
/**
|
||||
* Centralized secrets management — single source of truth for all sensitive data.
|
||||
*
|
||||
* Load priority (highest to lowest):
|
||||
* 1. /etc/ai-news-writer/secrets.env (injected by Gitea Actions / deployment tooling)
|
||||
* 2. .env (local development)
|
||||
* 3. process.env (already in environment, e.g., from PM2 env config)
|
||||
* 4. Defaults (where safe to provide)
|
||||
* Merge order (later assignments win — same key from a later source overrides earlier):
|
||||
* 1. process.env (baseline: shell, PM2, CI, etc.)
|
||||
* 2. /etc/ai-news-writer/secrets.env (production inject)
|
||||
* 3. repo .env (local development; overrides system file when both exist)
|
||||
*
|
||||
* Usage:
|
||||
* const secrets = require('./config/secrets');
|
||||
|
||||
@@ -104,6 +104,15 @@ function validateSources(sourcesConfig) {
|
||||
warnings.push('sources.trusted_domains: not configured');
|
||||
}
|
||||
|
||||
if (sourcesConfig.domain_filter_mode !== undefined && sourcesConfig.domain_filter_mode !== null) {
|
||||
const mode = sourcesConfig.domain_filter_mode;
|
||||
if (typeof mode !== 'string' || !['strict', 'warn', 'log'].includes(mode)) {
|
||||
errors.push(
|
||||
`sources.domain_filter_mode: must be strict|warn|log (got ${typeof mode === 'string' ? JSON.stringify(mode) : typeof mode})`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
valid: errors.length === 0,
|
||||
errors,
|
||||
|
||||
@@ -15,7 +15,8 @@ test('validateSources — valid config', () => {
|
||||
}
|
||||
],
|
||||
keywords: ['football', 'basketball'],
|
||||
trusted_domains: ['bbc.co.uk']
|
||||
trusted_domains: ['bbc.co.uk'],
|
||||
domain_filter_mode: 'warn'
|
||||
};
|
||||
|
||||
const result = validateSources(config);
|
||||
@@ -23,6 +24,26 @@ test('validateSources — valid config', () => {
|
||||
assert.equal(result.errors.length, 0);
|
||||
});
|
||||
|
||||
test('validateSources — invalid domain_filter_mode', () => {
|
||||
const config = {
|
||||
rss: [
|
||||
{
|
||||
name: 'BBC Sport',
|
||||
url: 'https://feeds.bbci.co.uk/sport/rss.xml',
|
||||
category: 'sports',
|
||||
lang: 'en'
|
||||
}
|
||||
],
|
||||
keywords: ['football'],
|
||||
trusted_domains: ['bbc.co.uk'],
|
||||
domain_filter_mode: 'relaxed'
|
||||
};
|
||||
|
||||
const result = validateSources(config);
|
||||
assert.equal(result.valid, false);
|
||||
assert(result.errors.some((e) => e.includes('domain_filter_mode')));
|
||||
});
|
||||
|
||||
test('validateSources — missing rss field', () => {
|
||||
const config = {
|
||||
keywords: ['football'],
|
||||
|
||||
@@ -69,7 +69,7 @@ describe('status-server', () => {
|
||||
delete process.env.OPENAI_API_KEY;
|
||||
delete process.env.AI_MODEL;
|
||||
delete process.env.CRON_TIMEZONE;
|
||||
delete process.env.BODY_READ_TIMEOUT_MS;
|
||||
delete process.env.HTTP_BODY_READ_TIMEOUT_MS;
|
||||
});
|
||||
|
||||
it('returns object with feature flags', () => {
|
||||
|
||||
Reference in new issue
Block a user