mirror of
https://github.com/mksglu/context-mode.git
synced 2026-11-23 13:11:14 +08:00
chore(repo): remove metrics/ and the traffic workflow (D-REPO-NO-METRICS-1)
Owner: the metrics/ directory had no purpose on its own. The live-skip streak moves to e2e/live/skip-streak.json. traffic.yml, merge-traffic.mjs and its tests are removed; README badges read stats.json from readme-stats.yml. The repo-hygiene test fails if metrics/ exists. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bbee5c28db
commit
9231718c6e
14 files changed
+26
-327
No files matched your search
@@ -8,7 +8,7 @@ Release context-mode v2 (ADR-0013). Starting the skill is the approval for this
|
||||
1. Check the start state. Run `git branch --show-current` and `git status --porcelain`. The branch must be `v2` and the tree must be clean; if not, stop and report what is dirty. Run `gh auth status` and `git pull --ff-only`.
|
||||
2. Run the E2E cases: `node e2e/cases/run.mjs`. If a row is `FAIL`, stop and report the failing case ids.
|
||||
3. Run the v1 KEEP-PASS unit tests (GS4). `npm ci` installs the dev toolchain only (ADR-0013 "Trust boundary"); users never run npm. Then run `npx vitest run`. If one of the 131 tracked tests fails, stop and show its name.
|
||||
4. Run the live test: `node e2e/live/run.mjs --all` (Sonnet 5, effort low, ADR-0017) and show its table. If a row is `FAIL`, stop. Then update the live-skip streak in `metrics/live-skip-streak.json` (`{ "streak": <n> }`): if the table has one or more `SKIPPED` rows, add 1 to `streak`; if it has none, reset it to 0. If the file changed, commit it on `v2` and push. If `streak` is now `LIVE_SKIP_LIMIT` (3) or more, refuse to continue: report which cases were skipped and the note on each row.
|
||||
4. Run the live test: `node e2e/live/run.mjs --all` (Sonnet 5, effort low, ADR-0017) and show its table. If a row is `FAIL`, stop. Then update the live-skip streak in `e2e/live/skip-streak.json` (`{ "streak": <n> }`): if the table has one or more `SKIPPED` rows, add 1 to `streak`; if it has none, reset it to 0. If the file changed, commit it on `v2` and push. If `streak` is now `LIVE_SKIP_LIMIT` (3) or more, refuse to continue: report which cases were skipped and the note on each row.
|
||||
5. v1 migration checkpoint (GS10). The cases `e2e/live/cases/v1-migration-*.json` ran in step 4 (their `covers` paths include `v1-transition`, so `--all` selects them). Do not run them again; confirm each one is `PASS` in the step 4 table, and stop if one is not.
|
||||
6. Preview. Run `node scripts/release/plan.mjs --dry-run`. Show the owner the next version and the release notes. If it says there is nothing to release, stop.
|
||||
7. Start the release: `gh workflow run release.yml --ref v2 -f sha=$(git rev-parse HEAD)`.
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
# impl/13 §14.1, ADR-0011 §Metrics. Weekly: merge GitHub's 14-day clone/view traffic into
|
||||
# metrics/traffic.json by timestamp; commit only when the file changed.
|
||||
# Lives on main (D-M6-arch-7: the owner adds it to main once). DEVIATIONS D-M6-W1-1, D-M6-W1-2.
|
||||
name: traffic
|
||||
on:
|
||||
schedule: [{ cron: "0 3 * * 1" }]
|
||||
workflow_dispatch: {}
|
||||
permissions:
|
||||
contents: write
|
||||
jobs:
|
||||
traffic:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- env:
|
||||
GH_TOKEN: ${{ secrets.TRAFFIC_TOKEN }}
|
||||
run: |
|
||||
gh api "repos/$GITHUB_REPOSITORY/traffic/clones?per=day" > /tmp/clones.json
|
||||
gh api "repos/$GITHUB_REPOSITORY/traffic/views?per=day" > /tmp/views.json
|
||||
node scripts/release/merge-traffic.mjs /tmp/clones.json /tmp/views.json metrics/traffic.json
|
||||
- run: |
|
||||
git add metrics/traffic.json
|
||||
git diff --cached --quiet -- metrics/traffic.json && exit 0
|
||||
git config user.name "context-mode-bot"; git config user.email "noreply@example.invalid"
|
||||
git commit -m "traffic: weekly update" && git push
|
||||
@@ -101,7 +101,7 @@ const SELF = "build/check-removed.mjs";
|
||||
const ALLOWED_DIRS = [
|
||||
"src/core/", "src/prompt/", "src/entries/",
|
||||
"src/cli/", "src/setup/", // ADR-0019 D5-D7: npm CLI and setup engine (D-CR-0019-1)
|
||||
"tests/_lib/", "tests/fixtures/", "tests/e2e/", "tests/ops/", "e2e/", "build/", "bench/", "metrics/",
|
||||
"tests/_lib/", "tests/fixtures/", "tests/e2e/", "tests/ops/", "e2e/", "build/", "bench/",
|
||||
"docs/architecture/", "docs/install/",
|
||||
"docs/assets/readme/", // README figures and their sources (D-README-THESIS-1)
|
||||
"scripts/release/",
|
||||
|
||||
@@ -125,3 +125,4 @@ Split: this file holds the deviation rows without a date (format: id, files, dec
|
||||
| D-EXEC-PREVIEW-1 | src/core/contracts/constants.ts (`EXEC_PREVIEW_BYTES` 4096), src/core/tools/execute.ts (finish), tests/prd9-sandbox.test.mjs (new test) | A ctx_execute output that does not fit OUTPUT_CAP was indexed and the reply carried 14-16 KB of selected chunks (bench group D: 14.6, 15.7, 16.4, 15.1 KB for 78-651 KB of output). The ~14 KB was only what is left of OUTPUT_CAP (16384) after the head and `more:` line (D-M2-T10-6, D-M2-6); no number backed it. The model reaches the rest with the `ctx_search({queries:[...], source:"ctx_execute:..."})` line the reply ends with, and the replace path already sets its own smaller sizes (D-M7-SV-1..3, REPLACE_RETURN_BYTES 96). New budget for output over OUTPUT_CAP and no intent: EXEC_PREVIEW_BYTES = 4096 for head + whole chunks + `more:` line. Whole chunks only, the full output stays indexed, the pointer line stays. An intent still gets the full OUTPUT_CAP budget when the output fits OUTPUT_CAP. Bench D before/after (reply B, saved%): 120 KB log 14610 to 2319 (82% to 97%), 1 MB log 15671 to 3380 (98% to 99%), GitHub JSON 16353 to 4060 (93% to 98%), git log 15133 to 2842 (92% to 99%); markers found 3/3 in all four (before and after); exec ms 90/125/195/342 before, 56/101/73/77 after (less text to select and send; median of 3). Not measured: values under 4096 (chunks can be up to MAX_CHUNK_BYTES 4096, so a smaller budget can select no whole chunk). |
|
||||
| D-README-NO-SCOPE-1 | README.md (the "## Scope" section removed), tests/0014-repo-hygiene.test.mjs (README parts test: no "## Scope", "## Limitations" or "## Known" section, no OPEN-ITEMS pointer) | Owner, 2026-11-01, on the README Scope section: "bu kisma gerek yok ne icin var anlamadim". He said the same of the Limitations section before. The README keeps no section for scope, limits or open work; the fact that `ctx_execute` code runs as the user stays in section 7 (Security model). Open work stays in docs/v2/OPEN-ITEMS.md. |
|
||||
| D-PATH-LABEL-1 | src/core/store/fts.ts (pathLabel, storedLabel, resolveSourceLabel), src/core/store/schema.ts (DDL_V6), src/core/contracts/constants.ts (SCHEMA_VERSION 6), src/core/tools/index.ts (pathItems, itemsOf), src/core/tools/purge.ts, bench/suite/lib.mjs (qualityMisses, savedCell, indexedLabel), bench/run.mjs, bench/b-retrieval/index.mjs, tests/prd8-index-search.test.mjs (3 tests, one Windows only), tests/prd12-stats-purge.test.mjs, tests/0002-store.test.mjs (v6 migration), tests/0012-m2-bench.test.mjs, tests/0018-contracts.test.mjs | Windows retest 2026-11-01 (Codex 0.166, Claude Desktop, next.23): ctx_index({path:"data/sqlite-fts5-docs.html"}) stored and returned the label "data\\sqlite-fts5-docs.html" (node:path join and relative use the OS separator); ctx_search with source:"data/sqlite-fts5-docs.html" gave "No hits ... across 0 source(s)" because the filter is `label = :source` (3/3 questions fail in 3 fresh runs; nested/notes.md gave 0 hits, nested\\notes.md gave 1). Root cause: the label is a name the agent types back, but it was built with the OS separator and compared by exact text. Now a path label has one form on every OS: forward slashes, relative to the project (`pathLabel`). The `source` argument of ctx_search and ctx_purge takes either slash form: the argument as typed if a row has it, else its forward-slash form (`storedLabel`). Schema version 6 renames existing backslash path labels in place (`UPDATE sources SET label = replace(label, char(92), '/') WHERE kind = 'path'`): no source or chunk row is deleted or rewritten, content and url labels are not touched, so data stored on Windows before the fix stays findable. The harness (bench/b-retrieval) now searches with the label ctx_index returned. A scenario whose own check fails (WARN, answers < expected) is a quality miss: bench/run.mjs prints `MISS`, a QUALITY MISS list and a count in the last line, writes `quality_misses` into the results JSON, and the table row shows `miss` where a saving would stand (before, the row printed WARN, exited 0 and showed a saving). Loss: a non-Windows path with a literal backslash in a file name is now labelled with a slash (rare; the file is still found by path). | New behaviour on all OSes for path labels; macOS and Linux labels are unchanged (no backslash). Windows-only test runs on the windows-latest CI job. |
|
||||
| D-REPO-NO-METRICS-1 | `metrics/` (deleted), `e2e/live/skip-streak.json` (moved from `metrics/live-skip-streak.json`), `.github/workflows/traffic.yml` and `scripts/release/merge-traffic.mjs` (deleted), `build/check-removed.mjs`, `.claude/skills/release/SKILL.md`, `tests/0011-v1-transition.test.mjs`, `tests/0014-repo-hygiene.test.mjs`, ADR-0011, ADR-0013, ADR-0015, ADR-0019, `docs/architecture/modules/13-build-release.md` | Owner, 2026-11-01: "https://github.com/mksglu/context-mode/tree/v2-design/metrics - bu dizinin amaci nedir anlamadim sil gerek yoksa tek basina kalmis burda boyle". The directory held one file, the live-skip streak counter, next to a traffic workflow that wrote `metrics/traffic.json`. The README badges now read `stats.json` from `readme-stats.yml` (D-README-STATS-1), so the traffic workflow, its merge script and its 8 tests are removed. The streak counter is next to the live harness in `e2e/live/skip-streak.json`. The repo-hygiene test fails if `metrics/` exists. |
|
||||
@@ -59,7 +59,7 @@ Status: accepted 2026-10-30, move done. Decision record: [ADR-0024](adr/0024-tes
|
||||
| 0019-host-config | ADR-0019, ADR-0023, PRD-setup | `tests/0019-host-config.test.mjs` | host config read/write, TOML, plugin root and swap, uninstall | 121 | 1.8 |
|
||||
| 0019-cli | ADR-0019, PRD-setup | `tests/0019-cli.test.mjs` | the context-mode CLI | 59 | 35.6 |
|
||||
| 0010-doctor-upgrade | ADR-0010, PRD-v2 section 13, GP11 | `tests/0010-doctor-upgrade.test.mjs` | doctor, upgrade, release fetch, checksums, report | 124 | 12.9 |
|
||||
| 0011-v1-transition | ADR-0011, GP11 | `tests/0011-v1-transition.test.mjs` | v1 detect and remove, v1 migration, merge traffic | 44 | 1.7 |
|
||||
| 0011-v1-transition | ADR-0011, GP11 | `tests/0011-v1-transition.test.mjs` | v1 detect and remove, v1 migration | 44 | 1.7 |
|
||||
| 0013-release-main | ADR-0013, PRD-v2 section 14 | `tests/0013-release-main.test.mjs` | release to main: publish, plan-main, commit, branch protection | 43 | 22.0 |
|
||||
| 0013-release-plan | ADR-0013, ADR-0019, PRD-v2 section 14 | `tests/0013-release-plan.test.mjs` | release plan, smoke, rollback, npm publish | 60 | 23.6 |
|
||||
| 0014-repo-hygiene | ADR-0013, ADR-0014, ADR-0015 | `tests/0014-repo-hygiene.test.mjs` | issue forms, workflows, README, secrets, removed files | 80 | 3.6 |
|
||||
|
||||
@@ -78,16 +78,8 @@ Facts:
|
||||
|
||||
## Metrics (G23)
|
||||
|
||||
- New workflow `traffic.yml`:
|
||||
- cron `0 3 * * 1` (weekly)
|
||||
- `permissions: contents: write`
|
||||
- token: secret `TRAFFIC_TOKEN`, a fine-grained PAT with Administration: read
|
||||
- It runs:
|
||||
- `gh api "repos/$GITHUB_REPOSITORY/traffic/clones?per=day"`
|
||||
- `gh api "repos/$GITHUB_REPOSITORY/traffic/views?per=day"`
|
||||
- It merges the results into `metrics/traffic.json` by timestamp. The 14-day window spans two weekly runs, so one failed run loses nothing.
|
||||
- It commits only when the file changed.
|
||||
- Retire `update-stats.yml`: it adds all-time npm counts to 14-day clone counts every 6 hours. Point the README badges at `metrics/traffic.json`.
|
||||
- The README badges read `stats.json` (`npm_downloads`, `stars`). The workflow `.github/workflows/readme-stats.yml` writes it each day with `GITHUB_TOKEN` only (D-README-STATS-1). It replaces `update-stats.yml`.
|
||||
- The repo has no `metrics/` directory (D-REPO-NO-METRICS-1). The live-skip streak is in `e2e/live/skip-streak.json`.
|
||||
|
||||
## r3 decision (2026-10-14, `https://github.com/mksglu/context-mode/blob/274600e2ffab843e89c1dfa09b0d649e650c962f/docs/v2/review/DECISIONS-r3.md`)
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
| `codex plugin marketplace add owner/repo@ref` also works with no login | same, for Codex |
|
||||
| release-please and changesets assume an npm package or a manifest at the branch tip | they do not fit a `release` branch that holds only build output. A dependency-free script of about 50 lines is used instead |
|
||||
| Pull requests are already disabled on the repo | no PR workflows and no Dependabot PRs |
|
||||
| GitHub disables scheduled workflows after 60 days with no repo activity | the weekly traffic commit keeps the schedules alive [U] |
|
||||
| GitHub disables scheduled workflows after 60 days with no repo activity | the daily `readme-stats.yml` commit keeps the schedules alive [U] |
|
||||
|
||||
## Design
|
||||
|
||||
@@ -45,7 +45,6 @@ Trigger: `workflow_dispatch` only (input `sha`, or `mode: rollback`). The `/rele
|
||||
### Other workflows
|
||||
|
||||
On `main` (one owner-approved commit; `package.json` is not touched):
|
||||
- `traffic.yml`: weekly
|
||||
- `weekly.yml`: install smoke from `@release`, a check that repo settings have not drifted, `npm audit` of a v2 checkout
|
||||
- removed at the same time: `bundle.yml`, `update-stats.yml`, `openclaw-e2e.yml`, `tier2-e2e-smoke.yml`
|
||||
|
||||
@@ -61,7 +60,7 @@ On `v2`:
|
||||
## Decided 2026-10-14
|
||||
|
||||
- Releases are frequent, so there is no per-release live-test gate in CI. The skill runs the live harness by default; `skip-live` is allowed and is written into the release notes.
|
||||
- `traffic.yml` and `weekly.yml` go to `main` (owner: "main'e ekleyelim").
|
||||
- `weekly.yml` goes to `main` (owner: "main'e ekleyelim").
|
||||
- No signed tags, no `release` environment approval.
|
||||
|
||||
## r3 decision (2026-10-14, `https://github.com/mksglu/context-mode/blob/274600e2ffab843e89c1dfa09b0d649e650c962f/docs/v2/review/DECISIONS-r3.md`)
|
||||
|
||||
@@ -9,7 +9,7 @@ Target length is about 165 lines, with a CI cap of 200. Written in English.
|
||||
|
||||
| # | Section | Lines | Content |
|
||||
|---|---|---|---|
|
||||
| 1 | Title, tagline, badges | 7 | 3 badges: clones (`metrics/traffic.json`), stars, license. The npm, users, HN and 18 empty logo badges are removed |
|
||||
| 1 | Title, tagline, badges | 7 | 3 badges: npm downloads and stars (both read from `stats.json`, written by `readme-stats.yml`), license. The npm, users, HN and 18 empty logo badges are removed |
|
||||
| 2 | Callout | 4 | "Install with `npm i -g context-mode && context-mode setup` (ADR-0019; the Claude Code marketplace still uses the git `release` branch). Coming from v1? See Upgrading from v1." |
|
||||
| 3 | What it does | 12 | the problem in 3 lines, then 3 bullets: sandbox tools, one index per project with search, state after compaction |
|
||||
| 4 | `## Install` | 28 | Keep this exact heading: ADR-0019 removed the npm deprecate step; v1 reporters still reach the install steps through `#install`. A 10-row table: Agent, Command, Guide. **A row gets a command only after a live install test on that agent passes.** Until then it says "see guide" |
|
||||
|
||||
@@ -125,7 +125,7 @@ Tests: golden `--help` output per command; exit code per failure class; no-TTY r
|
||||
- Install is two commands for every agent, the same on macOS, Linux and Windows.
|
||||
- 10 install docs become one page plus per-agent troubleshooting.
|
||||
- `check-install-docs.mjs` changes: it allows `npm i -g context-mode` and `context-mode setup`, still bans user paths.
|
||||
- npm download counts return as a metric; GitHub traffic (G23) stays as a second source.
|
||||
- npm download counts return as a metric. The README badges read them from `stats.json`, written by `readme-stats.yml`.
|
||||
- The release job publishes by npm trusted publishing (OIDC, provenance, no long-lived token), behind the `npm-publish` environment with the owner as required reviewer (S-NPM).
|
||||
- The stored absolute path holds the node version dir under nvm, fnm, Volta and the CI toolcache, so it can go stale after a node switch. `doctor` checks that the stored path exists; `setup` and `upgrade` rewrite it (S-PATH).
|
||||
- More code than a doc page. It replaces the `node -e` writers in the docs, and it reuses the adapter table and `ctx_upgrade` logic.
|
||||
|
||||
@@ -368,34 +368,9 @@ Not shipped to users (release-only, repo-local skill, excluded from the built tr
|
||||
|
||||
**E2E proof:** this skill's steps are rehearsed by the owner, not by an automated case (it is the thing that triggers the automated layers below it); `release.yml`'s `ci`+`smoke` jobs are the proof that what the skill dispatches actually works. ADR-0017 `covers`: `.claude/skills/release/SKILL.md`.
|
||||
|
||||
## 14. `.github/workflows/traffic.yml` and `weekly.yml`
|
||||
## 14. `.github/workflows/weekly.yml`
|
||||
|
||||
Named in ADR-0011 §Metrics and ADR-0013 §Other workflows; both go on `main` (owner: "main'e ekleyelim"), both owned by this module since they are CI/release-adjacent plumbing, not product code.
|
||||
|
||||
### 14.1 `traffic.yml`
|
||||
```yaml
|
||||
name: traffic
|
||||
on:
|
||||
schedule: [{ cron: "0 3 * * 1" }]
|
||||
workflow_dispatch: {}
|
||||
permissions:
|
||||
contents: write
|
||||
jobs:
|
||||
traffic:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- env: { GH_TOKEN: ${{ secrets.TRAFFIC_TOKEN }} }
|
||||
run: |
|
||||
gh api "repos/$GITHUB_REPOSITORY/traffic/clones?per=day" > /tmp/clones.json
|
||||
gh api "repos/$GITHUB_REPOSITORY/traffic/views?per=day" > /tmp/views.json
|
||||
node scripts/release/merge-traffic.mjs /tmp/clones.json /tmp/views.json metrics/traffic.json
|
||||
- run: |
|
||||
git diff --quiet metrics/traffic.json && exit 0
|
||||
git config user.name "context-mode-bot"; git config user.email "noreply@example.invalid"
|
||||
git add metrics/traffic.json && git commit -m "traffic: weekly update" && git push
|
||||
```
|
||||
`merge-traffic.mjs` merges by timestamp into the 14-day rolling window file, so one missed weekly run loses no data (ADR-0011 §Metrics).
|
||||
Named in ADR-0013 §Other workflows; it goes on `main` (owner: "main'e ekleyelim"), owned by this module since it is CI/release-adjacent plumbing, not product code. The README badge counts come from `.github/workflows/readme-stats.yml` (`stats.json`, D-README-STATS-1); there is no traffic workflow (D-REPO-NO-METRICS-1).
|
||||
|
||||
### 14.2 `weekly.yml`
|
||||
```yaml
|
||||
@@ -417,14 +392,14 @@ jobs:
|
||||
- run: npm install && npm audit --audit-level=high
|
||||
```
|
||||
|
||||
**E2E proof:** both workflows run for real on `main` on a schedule; there is no GP/live case (they run outside the `v2` CI surface by design — ADR-0013 keeps them off `v2`). ADR-0017 `covers`: `.github/workflows/traffic.yml`, `.github/workflows/weekly.yml`, `scripts/release/merge-traffic.mjs`, `scripts/release/check-branch-protection.mjs`.
|
||||
**E2E proof:** the workflow runs for real on `main` on a schedule; there is no GP/live case (they run outside the `v2` CI surface by design — ADR-0013 keeps them off `v2`). ADR-0017 `covers`: `.github/workflows/weekly.yml`, `scripts/release/check-branch-protection.mjs`.
|
||||
|
||||
## Assumptions
|
||||
|
||||
- A9: `scripts/release/{plan,publish,smoke,rollback}.mjs`, `branch-protection.mjs`, `branch-protection-settings.json`, `merge-traffic.mjs`, `check-branch-protection.mjs` are added as files this module owns, under `scripts/release/`. 00 §1 names `release.yml`'s jobs (plan/build/publish/smoke) and ADR-0013's branch-protection script by filename but 00's file tree table has no `scripts/` row; `scripts/` is the natural home (it already exists in the repo for other one-off tooling) and keeps `release.yml`'s YAML free of multi-step inline shell that 00's "no regex / staged git plumbing" needs real control flow for.
|
||||
- A9: `scripts/release/{plan,publish,smoke,rollback}.mjs`, `branch-protection.mjs`, `branch-protection-settings.json`, `check-branch-protection.mjs` are added as files this module owns, under `scripts/release/`. 00 §1 names `release.yml`'s jobs (plan/build/publish/smoke) and ADR-0013's branch-protection script by filename but 00's file tree table has no `scripts/` row; `scripts/` is the natural home (it already exists in the repo for other one-off tooling) and keeps `release.yml`'s YAML free of multi-step inline shell that 00's "no regex / staged git plumbing" needs real control flow for.
|
||||
- A10: `release.yml`'s `ci` job reuses `ci.yml` via `workflow_call`, so `ci.yml` declares both `on: push` and `on: workflow_call`. ADR-0013 says only "reuses `ci.yml`" without naming the GitHub Actions mechanism; `workflow_call` is the only reuse mechanism that runs the identical job definition rather than duplicating the matrix.
|
||||
- A11: `plan.mjs`'s version source when `release` does not exist yet is `0.0.0` bumped to `0.1.0` is replaced by the plugin manifest's literal first value `"2.0.0"` (ADR-0011 §Release steps 1a: "set `version: 2.0.0`... the first time"). The very first `/release` run is therefore a special case the owner runs once by hand, matching ADR-0011's "Each outward step is approved separately" — `plan.mjs` detects "no `release` branch" and prints version `2.0.0` instead of computing a bump, rather than failing.
|
||||
- A12: `LIVE_SKIP_LIMIT` streak tracking (§13 step 4) is stored in `metrics/live-skip-streak.json` on `v2` (committed by the skill run, like `metrics/traffic.json`'s commit-only-when-changed pattern) because ADR-0013 names the limit but not where the running count persists across separate `/release` invocations.
|
||||
- A12: `LIVE_SKIP_LIMIT` streak tracking (§13 step 4) is stored in `e2e/live/skip-streak.json` on `v2` (committed by the skill run only when the file changed) because ADR-0013 names the limit but not where the running count persists across separate `/release` invocations.
|
||||
- A13: `check-removed.mjs` (GS5 file-existence half) stays owned by `v1-transition` per 00 §1's module table; this file's §7 `lint.mjs` only implements the byte-level half (GS5's `lint.mjs` clause + GS9), not the file-existence half, to avoid owning across the module boundary 00 §2 draws.
|
||||
- A14 (S7): `build/build.mjs` step 2 names no esbuild version. No ADR or impl file pins one. Decided here with the smallest rule consistent with GS7 (no `node_modules`, no `dependencies` on `release`, dev-only tool): pin the exact version `esbuild@0.24.0` (current stable at doc time) as a dev dependency, no range operator, so a `npm install` on two machines builds byte-identical output. A version bump is a separate, reviewed change, never an automatic range update.
|
||||
- A15 (S7): the CI matrix's exact Node "current" line (§9/§13, "3 OS × Node 24.15.0 and current") is `24.15.0` (the `NODE_MIN` floor) and `26` (latest tested, per S-NODE) — already named at §9; this row only cross-references it so §2.2 readers do not re-ask the question.
|
||||
|
||||
File renamed without changes.
@@ -1,125 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
// scripts/release/merge-traffic.mjs — impl/13 §14.1, ADR-0011 §Metrics, DEVIATIONS D-M6-W1-1.
|
||||
//
|
||||
// Usage: node scripts/release/merge-traffic.mjs <clones.json> <views.json> <traffic.json>
|
||||
//
|
||||
// <clones.json> and <views.json> are the raw bodies of
|
||||
// gh api "repos/$GITHUB_REPOSITORY/traffic/clones?per=day"
|
||||
// gh api "repos/$GITHUB_REPOSITORY/traffic/views?per=day"
|
||||
// Each one is { count, uniques, <kind>: [{ timestamp, count, uniques }] } and covers the last
|
||||
// 14 days. The weekly run merges both into <traffic.json> by timestamp:
|
||||
// - every day already in the file stays (the file keeps all history, so one missed weekly
|
||||
// run loses nothing: the next run's 14 days reach back over the missed week);
|
||||
// - a day in the new body replaces the same timestamp in the file (GitHub's newest figure
|
||||
// wins: the last day of the previous run was still partial);
|
||||
// - count and uniques are GitHub's own 14-day totals from the newest body (the README badge
|
||||
// reads $.clones.count); they are not summed from the days.
|
||||
// The output is deterministic (sorted days, no run timestamp), so an unchanged window gives a
|
||||
// byte-identical file and the workflow commits only when the file changed.
|
||||
// Bad input: exit 1 with one stderr line, and the output file is not touched. Node built-ins only.
|
||||
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const KINDS = ["clones", "views"];
|
||||
|
||||
function fail(msg) {
|
||||
process.stderr.write(`merge-traffic: ${msg}\n`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
function readJson(file, label) {
|
||||
let text;
|
||||
try {
|
||||
text = readFileSync(file, "utf8");
|
||||
} catch (e) {
|
||||
fail(`cannot read ${label} ${file}: ${e.code ?? e.message}`);
|
||||
}
|
||||
try {
|
||||
return JSON.parse(text);
|
||||
} catch (e) {
|
||||
fail(`${label} ${file} is not JSON: ${e.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
const isCount = (n) => Number.isInteger(n) && n >= 0;
|
||||
|
||||
function isTimestamp(s) {
|
||||
if (typeof s !== "string") return false;
|
||||
const d = new Date(s);
|
||||
return !Number.isNaN(d.getTime()) && d.toISOString().replace(".000Z", "Z") === s;
|
||||
}
|
||||
|
||||
// Returns an error string, or null when `day` is one { timestamp, count, uniques } entry.
|
||||
function dayError(day) {
|
||||
if (day === null || typeof day !== "object" || Array.isArray(day)) return "a day is not an object";
|
||||
if (!isTimestamp(day.timestamp)) return `bad timestamp ${JSON.stringify(day.timestamp)}`;
|
||||
if (!isCount(day.count) || !isCount(day.uniques)) return `bad count/uniques at ${day.timestamp}`;
|
||||
return null;
|
||||
}
|
||||
|
||||
// Validates one GitHub traffic body for `kind` and returns it, or exits 1.
|
||||
function checkBody(body, kind, label) {
|
||||
if (body === null || typeof body !== "object" || Array.isArray(body)) fail(`${label}: not an object`);
|
||||
if (!isCount(body.count) || !isCount(body.uniques)) fail(`${label}: count/uniques missing or not counts`);
|
||||
if (!Array.isArray(body[kind])) fail(`${label}: no "${kind}" array`);
|
||||
for (const day of body[kind]) {
|
||||
const err = dayError(day);
|
||||
if (err) fail(`${label}: ${err}`);
|
||||
}
|
||||
return body;
|
||||
}
|
||||
|
||||
// The stored file: { clones: { count, uniques, days }, views: { count, uniques, days } }.
|
||||
function readStore(file) {
|
||||
if (!existsSync(file)) return { clones: { days: [] }, views: { days: [] } };
|
||||
const store = readJson(file, "traffic file");
|
||||
if (store === null || typeof store !== "object" || Array.isArray(store)) fail(`traffic file ${file}: not an object`);
|
||||
for (const kind of KINDS) {
|
||||
const days = store[kind]?.days;
|
||||
if (!Array.isArray(days)) fail(`traffic file ${file}: no ${kind}.days array`);
|
||||
for (const day of days) {
|
||||
const err = dayError(day);
|
||||
if (err) fail(`traffic file ${file}: ${kind}: ${err}`);
|
||||
}
|
||||
}
|
||||
return store;
|
||||
}
|
||||
|
||||
function mergeDays(oldDays, newDays) {
|
||||
const byTs = new Map();
|
||||
for (const d of oldDays) byTs.set(d.timestamp, d);
|
||||
for (const d of newDays) byTs.set(d.timestamp, d);
|
||||
return [...byTs.keys()]
|
||||
.sort()
|
||||
.map((ts) => {
|
||||
const d = byTs.get(ts);
|
||||
return { timestamp: d.timestamp, count: d.count, uniques: d.uniques };
|
||||
});
|
||||
}
|
||||
|
||||
export function mergeTraffic(store, bodies) {
|
||||
const out = {};
|
||||
for (const kind of KINDS) {
|
||||
const body = bodies[kind];
|
||||
out[kind] = { count: body.count, uniques: body.uniques, days: mergeDays(store[kind].days, body[kind]) };
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
function main(argv) {
|
||||
if (argv.length !== 3) fail("usage: merge-traffic.mjs <clones.json> <views.json> <traffic.json>");
|
||||
const [clonesFile, viewsFile, outFile] = argv;
|
||||
const bodies = {
|
||||
clones: checkBody(readJson(clonesFile, "clones body"), "clones", `clones body ${clonesFile}`),
|
||||
views: checkBody(readJson(viewsFile, "views body"), "views", `views body ${viewsFile}`),
|
||||
};
|
||||
const merged = mergeTraffic(readStore(outFile), bodies);
|
||||
mkdirSync(path.dirname(path.resolve(outFile)), { recursive: true });
|
||||
writeFileSync(outFile, JSON.stringify(merged, null, 2) + "\n");
|
||||
process.stdout.write(
|
||||
`merge-traffic: clones ${merged.clones.days.length} days, views ${merged.views.days.length} days -> ${outFile}\n`,
|
||||
);
|
||||
}
|
||||
|
||||
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) main(process.argv.slice(2));
|
||||
@@ -1,5 +1,5 @@
|
||||
// ADR-0011, GP11: the v1 to v2 transition. Detect v1 footprints, remove them, plant them in e2e setup, and the
|
||||
// merge-traffic script. One file per area (docs/architecture/TEST-LAYOUT.md).
|
||||
// ADR-0011, GP11: the v1 to v2 transition. Detect v1 footprints, remove them, and plant them in e2e setup.
|
||||
// One file per area (docs/architecture/TEST-LAYOUT.md).
|
||||
import { test, describe } from "node:test";
|
||||
import { CONC } from "./_lib/concurrency.mjs";
|
||||
import assert from "node:assert/strict";
|
||||
@@ -442,126 +442,3 @@ describe("GP11: v1 migration setup plants detectable footprints", { concurrency:
|
||||
assert.equal(readFileSync(path.join(dir, "settings.json"), "utf8"), "USER");
|
||||
});
|
||||
});
|
||||
|
||||
describe("ADR-0011: merge-traffic script", { concurrency: CONC }, () => {
|
||||
// Unit tests for scripts/release/merge-traffic.mjs (impl/13 §14.1, ADR-0011 §Metrics,
|
||||
// DEVIATIONS D-M6-W1-1). Runs the real script on scratch files.
|
||||
const REPO = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
||||
const SCRIPT = path.join(REPO, "scripts", "release", "merge-traffic.mjs");
|
||||
|
||||
const ts = (day) => `2026-10-${String(day).padStart(2, "0")}T00:00:00Z`;
|
||||
const days = (from, to, n = 10) => {
|
||||
const out = [];
|
||||
for (let d = from; d <= to; d++) out.push({ timestamp: ts(d), count: d * n, uniques: d });
|
||||
return out;
|
||||
};
|
||||
const body = (kind, list, count = 999, uniques = 99) => ({ count, uniques, [kind]: list });
|
||||
|
||||
function scratch(t) {
|
||||
const dir = mkdtempSync(path.join(tmpdir(), "cm-v2-traffic-"));
|
||||
t.after(() => rmSync(dir, { recursive: true, force: true }));
|
||||
return dir;
|
||||
}
|
||||
|
||||
function run(dir, clones, views, out = path.join(dir, "metrics", "traffic.json")) {
|
||||
const c = path.join(dir, "clones.json");
|
||||
const v = path.join(dir, "views.json");
|
||||
writeFileSync(c, typeof clones === "string" ? clones : JSON.stringify(clones));
|
||||
writeFileSync(v, typeof views === "string" ? views : JSON.stringify(views));
|
||||
const r = spawnSync(process.execPath, [SCRIPT, c, v, out], { encoding: "utf8" });
|
||||
return { status: r.status, stderr: r.stderr, out };
|
||||
}
|
||||
|
||||
const read = (f) => JSON.parse(readFileSync(f, "utf8"));
|
||||
|
||||
test("[M6] merge-traffic: first run writes both kinds with GitHub's 14-day totals and sorted days", (t) => {
|
||||
const dir = scratch(t);
|
||||
const r = run(dir, body("clones", days(1, 14).reverse(), 500, 50), body("views", days(1, 14, 3), 300, 30));
|
||||
assert.equal(r.status, 0, r.stderr);
|
||||
const f = read(r.out);
|
||||
assert.deepEqual(Object.keys(f), ["clones", "views"]);
|
||||
assert.equal(f.clones.count, 500);
|
||||
assert.equal(f.clones.uniques, 50);
|
||||
assert.equal(f.views.count, 300);
|
||||
assert.deepEqual(f.clones.days, days(1, 14));
|
||||
assert.deepEqual(f.views.days, days(1, 14, 3));
|
||||
});
|
||||
|
||||
test("[M6] merge-traffic: a later run keeps older days and the newest body wins on the same timestamp", (t) => {
|
||||
const dir = scratch(t);
|
||||
assert.equal(run(dir, body("clones", days(1, 14)), body("views", days(1, 14))).status, 0);
|
||||
const newer = days(8, 21, 100); // overlaps 8..14 with new figures (day 14 was partial)
|
||||
const r = run(dir, body("clones", newer, 777, 77), body("views", newer, 666, 66));
|
||||
assert.equal(r.status, 0, r.stderr);
|
||||
const f = read(r.out);
|
||||
assert.deepEqual(f.clones.days, [...days(1, 7), ...newer]);
|
||||
assert.deepEqual(f.views.days, [...days(1, 7), ...newer]);
|
||||
assert.equal(f.clones.count, 777);
|
||||
assert.equal(f.views.uniques, 66);
|
||||
});
|
||||
|
||||
test("[M6] merge-traffic: one missed weekly run loses no day (ADR-0011: the 14-day window spans two runs)", (t) => {
|
||||
const dir = scratch(t);
|
||||
assert.equal(run(dir, body("clones", days(1, 14)), body("views", days(1, 14))).status, 0);
|
||||
// the run for days 8..21 failed; the next run sees 15..28
|
||||
assert.equal(run(dir, body("clones", days(15, 28)), body("views", days(15, 28))).status, 0);
|
||||
const f = read(path.join(dir, "metrics", "traffic.json"));
|
||||
assert.deepEqual(f.clones.days.map((d) => d.timestamp), days(1, 28).map((d) => d.timestamp));
|
||||
});
|
||||
|
||||
test("[M6] merge-traffic: same input twice gives a byte-identical file (commit only when changed)", (t) => {
|
||||
const dir = scratch(t);
|
||||
const c = body("clones", days(3, 16));
|
||||
const v = body("views", days(3, 16));
|
||||
assert.equal(run(dir, c, v).status, 0);
|
||||
const first = readFileSync(path.join(dir, "metrics", "traffic.json"));
|
||||
assert.equal(run(dir, c, v).status, 0);
|
||||
assert.deepEqual(readFileSync(path.join(dir, "metrics", "traffic.json")), first);
|
||||
});
|
||||
|
||||
test("[M6] merge-traffic: extra fields from GitHub are not stored", (t) => {
|
||||
const dir = scratch(t);
|
||||
const c = { ...body("clones", [{ ...days(1, 1)[0], extra: 1 }]), extra: true };
|
||||
const r = run(dir, c, body("views", []));
|
||||
assert.equal(r.status, 0, r.stderr);
|
||||
assert.deepEqual(read(r.out).clones, { count: 999, uniques: 99, days: days(1, 1) });
|
||||
});
|
||||
|
||||
test("[M6] merge-traffic: bad input exits 1 with one stderr line and leaves the file untouched", (t) => {
|
||||
const dir = scratch(t);
|
||||
assert.equal(run(dir, body("clones", days(1, 2)), body("views", days(1, 2))).status, 0);
|
||||
const out = path.join(dir, "metrics", "traffic.json");
|
||||
const before = readFileSync(out);
|
||||
const bad = [
|
||||
["not JSON", "{", body("views", [])],
|
||||
["error body", { message: "Must have push access to repository" }, body("views", [])],
|
||||
["wrong kind array", body("views", days(1, 2)), body("views", [])],
|
||||
["bad timestamp", body("clones", [{ timestamp: "2026-10-01", count: 1, uniques: 1 }]), body("views", [])],
|
||||
["negative count", body("clones", [{ timestamp: ts(1), count: -1, uniques: 1 }]), body("views", [])],
|
||||
["views missing", body("clones", []), body("clones", [])],
|
||||
];
|
||||
for (const [label, c, v] of bad) {
|
||||
const r = run(dir, c, v);
|
||||
assert.equal(r.status, 1, label);
|
||||
assert.equal(r.stderr.trim().split("\n").length, 1, `${label}: ${r.stderr}`);
|
||||
assert.deepEqual(readFileSync(out), before, label);
|
||||
}
|
||||
});
|
||||
|
||||
test("[M6] merge-traffic: a corrupt stored file is an error, not a reset", (t) => {
|
||||
const dir = scratch(t);
|
||||
const out = path.join(dir, "traffic.json");
|
||||
writeFileSync(out, JSON.stringify({ clones: { days: "x" } }));
|
||||
const r = run(dir, body("clones", []), body("views", []), out);
|
||||
assert.equal(r.status, 1);
|
||||
assert.equal(readFileSync(out, "utf8"), JSON.stringify({ clones: { days: "x" } }));
|
||||
});
|
||||
|
||||
test("[M6] merge-traffic: wrong argument count exits 1 and writes nothing", (t) => {
|
||||
const dir = scratch(t);
|
||||
const r = spawnSync(process.execPath, [SCRIPT, path.join(dir, "a.json")], { encoding: "utf8" });
|
||||
assert.equal(r.status, 1);
|
||||
assert.match(r.stderr, /usage/);
|
||||
assert.equal(existsSync(path.join(dir, "a.json")), false);
|
||||
});
|
||||
});
|
||||
@@ -131,7 +131,7 @@ describe("ADR-0015 repo: removed-file gate (allow-list)", () => {
|
||||
"tests/0001-a.test.mjs": "x", "tests/_lib/a.mjs": "x", "e2e/cases/a.mjs": "x", "build/build.mjs": "x", "bench/a.mjs": "x",
|
||||
"docs/architecture/TECH-SPEC.md": "x", "docs/install/README.md": "x", "docs/tools.md": "x", "docs/UPSTREAM-CREDITS.md": "x",
|
||||
"scripts/gate.mjs": "x", "scripts/ci-gs4-lint.mjs": "x", "scripts/record-fixtures.mjs": "x", "scripts/release/plan.mjs": "x",
|
||||
".github/workflows/ci.yml": "x", "metrics/traffic.json": "{}",
|
||||
".github/workflows/ci.yml": "x",
|
||||
".claude/settings.json": "{}", ".claude-plugin/plugin.json": "{}", ".codex-plugin/mcp.json": "{}",
|
||||
".agents/plugins/marketplace.json": "{}",
|
||||
"README.md": "x", "CONTRIBUTING.md": "x", "LICENSE": "x", "tsconfig.json": "{}", ".gitignore": "x", ".gitattributes": "x",
|
||||
@@ -774,7 +774,7 @@ describe("ADR-0013 repo: /release skill", () => {
|
||||
"node e2e/cases/run.mjs",
|
||||
"npx vitest run",
|
||||
"node e2e/live/run.mjs --all",
|
||||
"metrics/live-skip-streak.json",
|
||||
"e2e/live/skip-streak.json",
|
||||
"e2e/live/cases/v1-migration-",
|
||||
"node scripts/release/plan.mjs --dry-run",
|
||||
"gh workflow run release.yml",
|
||||
@@ -816,8 +816,8 @@ describe("ADR-0013 repo: /release skill", () => {
|
||||
for (const s of ['ref: "release"', "adding workflows to `main`", "npm deprecate"]) assert.ok(BODY.includes(s), s);
|
||||
});
|
||||
|
||||
test("metrics/live-skip-streak.json starts at streak 0", () => {
|
||||
const j = JSON.parse(readFileSync(path.join(REPO, "metrics", "live-skip-streak.json"), "utf8"));
|
||||
test("e2e/live/skip-streak.json starts at streak 0", () => {
|
||||
const j = JSON.parse(readFileSync(path.join(REPO, "e2e", "live", "skip-streak.json"), "utf8"));
|
||||
assert.deepEqual(j, { streak: 0 });
|
||||
});
|
||||
});
|
||||
@@ -1120,6 +1120,11 @@ describe("ADR-0015 / ADR-0024 repo: no dev folders, no v2 dir names (D-REPO-CLEA
|
||||
assert.deepEqual(hits, []);
|
||||
});
|
||||
|
||||
test("metrics/ does not exist (D-REPO-NO-METRICS-1)", () => {
|
||||
assert.deepEqual(tracked.filter((f) => f.startsWith("metrics/")), []);
|
||||
assert.equal(existsSync(path.join(ROOT, "metrics")), false);
|
||||
});
|
||||
|
||||
test("no tracked file names tests/v2/, docs/v2/, tickets/ or .impl/ outside a SHA-pinned permalink", () => {
|
||||
const hits = [];
|
||||
for (const f of tracked) {
|
||||
|
||||
Reference in new issue
Block a user