Repository navigation
Commit d50b5fd
authored
feat: weekly competitor feature watch (#507)
## What this does
This adds a weekly feature watch to the competitor scan. Besides the
README checks the scan already does, it now watches 11 specific doc
sections on competitor sites (Mastra, MockServer and WireMock pages for
tool mocks, MCP, recording, sessions and so on). For each source it
extracts the named section, strips markup, hashes the text and runs a
few keyword checks. It then compares the result with the last run.
The last observed state lives in `scripts/competitive-watch-state.json`.
It is committed empty (`{}`), so the first run records every source as
`baseline`. Later runs report `no change`, or `changed` with the reason
(section text changed, a check flipped false to true with the matching
evidence, or the URL moved). The state is written together with the docs
and before the summary, and nothing is written on a dry run. If any
watched source can't be fetched, the run fails, names each failing
source, and writes no summary, so a half-checked week never looks clean.
Every scan summary now ends with a "## Feature watch" section: one row
per source with its competitor, the claims it backs, its status, the
reason, and any evidence. The workflow also counts a state-only change
as a change. That opens a report-only PR ("Competitor feature-watch
report", `chore:` commit) on a per-run branch,
`auto/competitive-matrix-<date>-<run id>`. The Slack notification now
carries the Feature watch section as a digest and the PR link, and it
uses a separate message (🔎) when only the watch changed. A failed PR
creation now reports as a failure instead of "PR created".
The README scan also gets detection rules for MCP rows: MCP tool
mocking, scenario-scoped MCP fixtures, and failing on undeclared or
unmocked MCP tools. Each rule requires an actual MCP tool or server
context near a mock word, with bounded proximity, so general text about
mock servers or unmocked HTTP calls doesn't match.
## What this does not do
The watch never edits the homepage matrix or the migration pages. Its
results are only for human review in the PR body and the Slack digest. A
watch change can't promote a cell to yes, partial or anything else; a
person decides that after reading the evidence. A test proves that a
watch-only change leaves the docs byte-identical.
## Reviewer note: live effect of the first run
The first scheduled run after merge will flip two public cells for
mock-llm, because its README documents MCP mocking and the new rule
detects it:
- Homepage matrix: mock-llm / "MCP tool mocking" goes from ✗ to ✓.
- `docs/migrate-from-mock-llm/`: "MCP protocol mocking" goes from ✗ to
✓.
Both flips come from this PR. A real dry run against the live READMEs
shows exactly those two mock-llm changes plus older piyook flips that
also appear on main without this PR. Please confirm the mock-llm cells
are correct before you merge the first report PR.
## Red-green evidence
Each step was proven on the real surface (live READMEs and doc pages, or
the workflow's own `run:` text in a local harness), plus unit tests.
- **MCP rules.** RED: a real dry-run scan on main finds no MCP feature
for any competitor, and the new unit tests fail 3 of 4. GREEN: the same
scan detects "MCP tool mocking" for mock-llm (`No -> Yes`, the only new
flip), and the tests pass 4 of 4.
- **Watch module.** RED: running `scripts/competitive-watch.ts` on main
fails with module not found. GREEN: two live runs record all 11 sources
as `baseline` with identical hashes. A source forced to a closed port
fails the run with `ECONNREFUSED` and names the source (exit 1).
- **Scan integration.** RED: on main the summary has no "## Feature
watch" section and `--watch-state` is ignored, and 13 new unit cases
fail. GREEN: the dry run ends the summary with 11 baseline rows and
writes no state. The real run writes the state after the docs and before
the summary. A forced fetch failure exits 1 with no summary. Mutating
the write order or the headline logic turns the tests red.
- **Workflow.** RED: on main, `actionlint` reports two SC2086 findings.
In the harness, a state-only change is dropped (`changed=false`), and a
failed PR creation still posts "PR created". GREEN: `actionlint` and
`zizmor` are clean. A state-only change opens a report PR on a per-run
branch, and Slack carries the digest and PR link. A failed PR creation
posts ❌.
- **Value check (end to end).** Three local runs follow the spec's
sequence. Run 1 on the empty seed records 11 baseline. Run 2 records 11
`no change`, the state stays byte-identical, and the workflow skips the
PR and posts ✅. Run 3, after one hash is edited, shows
`mockserver-ap-mcp` as changed, and the workflow opens a report-only PR
whose 🔎 digest names that source. A consumer proof added a new watch
entry in a scratch tree. It went red without the entry and green with
it, and the homepage was not promoted.
- **Surgical fix.** RED: with the earlier MCP rules, 7 false-positive
probes matched (for example "Unmocked requests fail with a 404", "By
default, unmocked HTTP calls are denied", "Run the mock server MCP
endpoint", "mockserver mcp support"). GREEN: all 7 are rejected, and the
live mock-llm README is still detected. In the workflow harness, the old
Create PR step listed and closed an older report PR. After the fix it
makes no `gh pr list` or `gh pr close` calls.
## Review
This went through three review rounds, then a surgical fix. Rounds 1 and
2 produced fixes that were folded into these commits. Round 3 was
stopped once scope was narrowed to the two reproduced, load-bearing
defects. The surgical fix tightened the three MCP keyword rules after
seven false-positive probes were confirmed red then green, as shown
above. It also removed the step that auto-closed superseded report PRs,
because that step could close an older report PR that carried a real
matrix change.
Before push, format, lint, typecheck, build and the full suite all
passed (309 files, 10318 tests). `actionlint` and `zizmor` are clean on
the workflow.
## Known follow-ups
- With real data, the scan PR headline never mentions the feature watch,
because rowless detections and manual checks are always present. Only
the "## Feature watch" section and Slack show it. We need to decide
whether the manual-check headline names watch changes too.
- Since the supersede-close step was removed, duplicate open report PRs
can pile up from week to week.
- Shared helpers (cell escaping, flag parsing, error text with cause,
HTML to text) are repeated across the scripts. They can move into a
`scripts/lib` module.
- Workflow hardening (all pre-existing behavior): the branch is pushed
before `gh pr create`, so a failed create leaves an orphan branch. The
failure Slack message doesn't say what failed. A run cancelled by
`cancel-in-progress` posts "update failed".13 files changed
Lines changed: 3379 additions & 102 deletions
File tree
- .github/workflows
- scripts
- src/__tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
41 | | - | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
42 | 45 | | |
43 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
44 | 52 | | |
45 | 53 | | |
46 | 54 | | |
| |||
50 | 58 | | |
51 | 59 | | |
52 | 60 | | |
| 61 | + | |
53 | 62 | | |
54 | 63 | | |
55 | 64 | | |
| 65 | + | |
| 66 | + | |
56 | 67 | | |
57 | 68 | | |
58 | 69 | | |
59 | | - | |
| 70 | + | |
| 71 | + | |
60 | 72 | | |
61 | | - | |
62 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
63 | 81 | | |
64 | | - | |
65 | | - | |
| 82 | + | |
| 83 | + | |
66 | 84 | | |
67 | | - | |
| 85 | + | |
| 86 | + | |
68 | 87 | | |
69 | 88 | | |
70 | 89 | | |
71 | 90 | | |
72 | 91 | | |
73 | 92 | | |
| 93 | + | |
| 94 | + | |
74 | 95 | | |
75 | 96 | | |
76 | 97 | | |
77 | 98 | | |
78 | | - | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
79 | 102 | | |
80 | 103 | | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
81 | 107 | | |
82 | 108 | | |
83 | 109 | | |
84 | 110 | | |
85 | 111 | | |
86 | 112 | | |
87 | 113 | | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
0 commit comments