Skip to content

chore: remove downstream-consumer + personal refs (OSS hygiene) - #3882

Merged
PierreBrisorgueil merged 1 commit into
masterfrom
chore/oss-neutralize-downstream-refs
Jun 16, 2026
Merged

chore: remove downstream-consumer + personal refs (OSS hygiene)#3882
PierreBrisorgueil merged 1 commit into
masterfrom
chore/oss-neutralize-downstream-refs

Conversation

@PierreBrisorgueil

@PierreBrisorgueil PierreBrisorgueil commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Public OSS hygiene — the stack must not reference its consumers. Removes ALL downstream-consumer + personal refs (24 files), keeping logic + tests green.

Functional:

  • posthog-context.middleware.js: CLI user-agent detection is now config-driven (config.analytics.cliUserAgentPattern, regex-source string; default '' = no detection). Was a hardcoded downstream-CLI pattern. Consumers opt in via config.
  • lib/helpers/config.js: genericized the downstream-named entries in the weak-dev-secret reject-list.

Comments/docs/tests: genericized downstream examples + incident provenance (ERRORS/MIGRATIONS/README/billing-README/RUNBOOKS/invitations-README/skills + test example env-names). Kept all pierreb-devkit self-identity + the maintainer contact email.

Lint clean, 2588 tests pass, coverage held. Final OSS self-grep: only the maintainer email remains (intentional).

Summary by CodeRabbit

  • New Features

    • Added configuration option for CLI user-agent pattern detection in analytics tracking.
  • Documentation

    • Updated documentation to use generic examples instead of project-specific references.
    • Clarified analytics source attribution conventions and billing migration procedures.
  • Chores

    • Updated test coverage with generic configuration examples.
    • Refreshed JWT secret validation references to use generic placeholder values.

Make the public stack consumer-agnostic. No real behaviour change:

- posthog-context middleware: CLI user-agent detection is now config-driven
  via config.analytics.cliUserAgentPattern (regex-source string). Empty/unset
  default -> no CLI detection (source stays 'web'). Removes the hardcoded
  downstream CLI user-agent literal.
- config helper: genericize the known-weak JWT secret reject-list to generic
  placeholders (ExampleNodeDevSecret / ChangeThisDevSecret).
- genericize downstream-named examples + incident provenance in code comments,
  config, docs (ERRORS.md, MIGRATIONS.md, README.md, RUNBOOKS.md, module READMEs,
  migration doc, update-stack skill) and tests.

Tests + lint green; coverage unchanged (gated server-side via Codecov).
Copilot AI review requested due to automatic review settings June 16, 2026 07:42
@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

Walkthrough

Replaces the hardcoded @trawlme/cli User-Agent pattern in posthogContextMiddleware with a config-driven regex (cliUserAgentPattern) sourced from an environment variable. Updates JWT_DEFAULT_SECRETS to use generic placeholder values (ExampleNodeDevSecret, ChangeThisDevSecret). Scrubs trawl-specific names and domain references from docs, inline comments, and test fixtures throughout the repository.

Changes

Config-driven CLI UA detection and JWT placeholder generalization

Layer / File(s) Summary
Config-driven CLI UA detection
config/defaults/development.config.js, lib/middlewares/posthog-context.middleware.js, lib/middlewares/tests/posthog-context.middleware.unit.tests.js
Adds analytics.posthog.cliUserAgentPattern config property sourced from DEVKIT_NODE_analytics_cliUserAgentPattern. Middleware replaces hardcoded regex with getCliUaRe() helper that compiles the config value at runtime; falls back to { source: 'web' } when unset. Tests refactored with a loadMiddleware(cliUserAgentPattern) helper covering both configured and unconfigured scenarios.
JWT_DEFAULT_SECRETS generalization
lib/helpers/config.js, lib/helpers/tests/config.isJwtSecretWeak.unit.tests.js, lib/helpers/tests/config.validateJwtSecret.unit.tests.js
Replaces downstream-specific JWT placeholder values in JWT_DEFAULT_SECRETS with ExampleNodeDevSecret, ChangeThisDevSecret, and the upstream placeholder. Test vectors updated to assert the new placeholders throw in production and log without throwing in dev/test/local.

Trawl reference de-branding

Layer / File(s) Summary
Trawl reference scrub across docs, comments, and test fixtures
README.md, ERRORS.md, MIGRATIONS.md, .claude/skills/update-stack/SKILL.md, docs/migrations/..., config/defaults/billing.pricing.constants.js, config/index.js, modules/billing/README.md, modules/billing/RUNBOOKS.md, modules/billing/middlewares/..., modules/billing/repositories/..., modules/billing/services/..., modules/core/tests/..., modules/invitations/README.md, lib/services/tests/analytics.capture.unit.tests.js, lib/services/tests/analytics.captureException.unit.tests.js, lib/services/tests/express.openapi-servers.unit.tests.js
Replaces trawl/trawl.me/trawl-billing-*/trawl-rewards/appTag: 'trawl' with generic equivalents (<project>, acme, myapp, api.example.com) across all referenced documentation, inline comments, runbooks, and test mock data.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

Possibly related PRs

  • pierreb-devkit/Node#3798: Both PRs update modules/billing/README.md with downstream cost-semantics boundary guidance for billing.meter.service.js.
  • pierreb-devkit/Node#3778: Both PRs modify the .claude/skills/update-stack/SKILL.md Phase 1 "3ter Block on drift" section — the retrieved PR rewrites it while this PR removes a trailing citation line.
  • pierreb-devkit/Node#3846: Both PRs scrub downstream/project-specific references from MIGRATIONS.md and related docs as part of the same "no-downstream refs" effort.

Suggested labels

Chore

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main functional and non-functional changes: removing downstream-consumer and personal references for OSS hygiene across 24 files.
Description check ✅ Passed The description covers core required sections (Summary, Scope, Validation) with clear functional changes, test results, and quality checks. Some optional sections like 'Before vs After' table are not included but are marked optional.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/oss-neutralize-downstream-refs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov

codecov Bot commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.50000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 92.66%. Comparing base (8e89a21) to head (e0ccd5c).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3882      +/-   ##
==========================================
- Coverage   92.67%   92.66%   -0.02%     
==========================================
  Files         169      169              
  Lines        5529     5535       +6     
  Branches     1776     1778       +2     
==========================================
+ Hits         5124     5129       +5     
- Misses        325      326       +1     
  Partials       80       80              
Flag Coverage Δ
integration 61.12% <62.50%> (-0.02%) ⬇️
unit 74.23% <87.50%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0e19de0...e0ccd5c. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@PierreBrisorgueil
PierreBrisorgueil merged commit ddc34d0 into master Jun 16, 2026
7 of 9 checks passed
@PierreBrisorgueil
PierreBrisorgueil deleted the chore/oss-neutralize-downstream-refs branch June 16, 2026 07:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes downstream-consumer and personal references across the stack for OSS hygiene, while keeping behavior stable. It also makes PostHog CLI source attribution opt-in via configuration instead of a hardcoded downstream CLI User-Agent pattern.

Changes:

  • Make posthog-context.middleware.js CLI detection config-driven via analytics.cliUserAgentPattern (regex-source string; empty disables detection).
  • Genericize the JWT weak-secret placeholder denylist in lib/helpers/config.js and adjust associated tests.
  • Scrub downstream/personal references from docs, runbooks, migrations notes, and test fixtures/examples.

Reviewed changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
README.md Genericize CLI source description + project override examples.
modules/invitations/README.md Remove downstream-specific module example naming.
modules/core/tests/core.unit.tests.js Replace downstream env-name example with a generic one.
modules/billing/services/billing.webhook.service.js Genericize downstream responsibility comment.
modules/billing/RUNBOOKS.md Replace downstream URLs/secret names/CronJob names with placeholders.
modules/billing/repositories/billing.subscription.repository.js Genericize downstream migration comment.
modules/billing/README.md Remove downstream-specific incident provenance; keep guidance generic.
modules/billing/middlewares/billing.requirePlan.js Genericize “downstream contract” wording in comment.
modules/billing/middlewares/billing.attachUsageContext.js Remove downstream-specific example mention in comment.
MIGRATIONS.md Remove downstream repo references and genericize downstream guidance.
lib/services/tests/express.openapi-servers.unit.tests.js Replace downstream domain fixture with generic domain.
lib/services/tests/analytics.captureException.unit.tests.js Replace downstream appTag test fixture with generic one.
lib/services/tests/analytics.capture.unit.tests.js Replace downstream appTag test fixture with generic one.
lib/middlewares/tests/posthog-context.middleware.unit.tests.js Update tests to cover config-driven CLI UA detection and “disabled when unset”.
lib/middlewares/posthog-context.middleware.js Switch hardcoded CLI UA detection to config-driven regex-source string.
lib/helpers/tests/config.validateJwtSecret.unit.tests.js Update placeholder-secret test fixtures to generic/upstream terms.
lib/helpers/tests/config.isJwtSecretWeak.unit.tests.js Update weak-secret placeholder coverage to generic/upstream terms.
lib/helpers/config.js Replace downstream-specific JWT placeholders with generic placeholders.
ERRORS.md Remove downstream repo references while keeping the actionable guidance.
docs/migrations/2026-05-01-billing-crons-module-relocation.md Remove downstream-specific example project mention.
config/index.js Genericize comment describing non-standard NODE_ENV usage.
config/defaults/development.config.js Add analytics.cliUserAgentPattern default (env-configurable, empty disables).
config/defaults/billing.pricing.constants.js Remove downstream-specific provenance from header comment.
.claude/skills/update-stack/SKILL.md Remove downstream-specific plan reference.

Comment on lines +15 to +28
/**
* Build the CLI User-Agent matcher from config, or `null` when unconfigured.
*
* @returns {RegExp|null} compiled regex, or `null` if no/invalid pattern is set
*/
const getCliUaRe = () => {
const pattern = config.analytics?.cliUserAgentPattern;
if (!pattern) return null;
try {
return new RegExp(pattern);
} catch {
return null;
}
};
Comment on lines +8 to 12
* Verifies config-driven User-Agent parsing for CLI vs web source attribution:
* 1. CLI UA with version → source:'cli', cli_version:'<version>'
* 2. CLI UA without explicit version segment → source:'cli' fallback
* 3. Web browser UA → source:'web'
* 4. Missing UA → source:'web'
Comment thread MIGRATIONS.md
Comment on lines 162 to 166
## Test DB isolation: per-pid Mongo database default + globalTeardown (2026-04-24)

Default test database is now `mongodb://127.0.0.1:27017/NodeTest_${process.pid}` instead of the shared `NodeTest`. Concurrent jest invocations (e.g. multiple agent worktrees running `npm run test:coverage` in parallel) get isolated databases, eliminating the 401 / 404 / 422 / `MongoPoolClosedError` flake patterns documented in trawl_node#980.
Default test database is now `mongodb://127.0.0.1:27017/NodeTest_${process.pid}` instead of the shared `NodeTest`. Concurrent jest invocations (e.g. multiple agent worktrees running `npm run test:coverage` in parallel) get isolated databases, eliminating the 401 / 404 / 422 / `MongoPoolClosedError` flake patterns seen in parallel runs.

### What changed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants