# Changelog of Xiaohongshu (REDnote) Note Tracker: English & Growth Deltas (`crawleast/xiaohongshu-note-tracker`) Actor

- **URL**: https://apify.com/crawleast/xiaohongshu-note-tracker/changelog.md
- **Full Actor documentation**: https://apify.com/crawleast/xiaohongshu-note-tracker.md

## Changelog

All notable changes to `xiaohongshu-note-tracker`. Version numbers here are the
`package.json` version; the Apify build number is separate and is recorded in
`cloud-tests/evidence/`.

### 0.1.10 — 2026-11-03

#### P0: the rednote.com page variant took the whole Actor dark for a day

From 2026-11-03 every `xiaohongshu.com/explore/<id>` request started answering
with a **two-hop redirect to `www.rednote.com/discovery/item/<id>`**, and that
page publishes its state object with a JS constructor in it:
`"originalCommentIds":new Set([])`. `JSON.parse` rejects that, so every note came
back `parse_failed` — **0 delivered, 0 charged, on a published Actor.**

| Shift (UTC) | run | delivered | build |
| --- | --- | --- | --- |
| 11-01 09:10 | `MJTFnbf4SbyXitdHY` | 2/2 ok, `note-fetched` 2 | 0.1.9 |
| 11-02 09:10 | `fSg1noH3KQEyZlhrv` | 2/2 ok, `note-fetched` 2 | 0.1.9 |
| **11-03 09:10** | **`xDc8UvKDdWQ23Uymu`** | **0/2, both `parse_failed`, charged 0** | **0.1.9** |
| 11-03 10:01 | `VfFYWquUs5itlTrLL` | 0/2 (different second note) | 0.1.9 |

All four ran **byte-identical canary input on the same build**, so this was never a
code regression — the platform moved under us. What it was *not*: not a wall
(HTTP 200, 370 KB of real page), not a redirect we refused (`redirect=none`; the
0.1.8 rednote fix already follows that hop), not note-specific, and not
IP-specific (datacenter and residential exits returned the same bytes and the
same construct). Every `noteDetailMap` field anchor is exactly where it was — the
whole note was lost to one non-JSON literal.

**Fix:** `normalizeStateLiteral()` walks the state literal once and rewrites
`new Set(<array>)` to the array it was built from, before `JSON.parse`. Only `Set`
is handled: `Map`, `Date` and friends have never been observed, and guessing their
JSON shape would turn a loud `parse_failed` into a silently wrong row. An
unhandled construct stays loud and lands in the diagnostics below.

**A latent data-corruption bug fixed on the way:** the old normalisation was
`blob.replace(/\bundefined\b/g, 'null')` — a blind string replace that also
rewrites *inside* string values. A note whose body legitimately contained the word
"undefined" was delivered to the customer edited. The new scan is string-aware, so
both rules apply only to real JS literals. Two tests pin this.

**New: `RUN_SUMMARY.diagnostics`** `{stateSanitized, stateParseFailures,
firstStateParseFailure {noteId, literalBytes, suspect, suspectAt, context}}`. This
outage left behind nothing but 20 characters of a V8 JSON message, and identifying
`new Set([])` as the culprit cost a live proxy probe. The next shape change is a
report read. `stateParseFailures` is guarded on the *terminal* verdict, so a note
whose first attempt failed to parse and whose retry hit a wall counts as a wall.

**Verification (0.1.10):** 197/197 offline (was 184; +13), and four mutation
controls — reverting to the 0.1.9 blind replace reddens 6 tests, making the scan
string-blind reddens exactly the 2 string-safety tests, and dropping the
terminal-verdict guard or switching `??=` to `=` each redden the diagnostics test.
All four restored byte-identical. Build `7E5Po7Sc0eTjgJcFl`, tag `latest`.

**This build was superseded the same day.** Its acceptance run came back 1 of 2
notes, not 2 of 2 — see 0.1.11. 0.1.10 is still strictly better than 0.1.9 (which
delivered 0 of 2), but it is not the fixed state and should not be cited as one.

### 0.1.11 — 2026-11-03

#### P0 follow-up: the acceptance run then exposed a second, independent failure mode

The fix was verified by re-running the canary's own input **verbatim** down the
default path (`eLmcbc9IOgcMObah7`, platform resolved build 0.1.10). It came back
**1 of 2**, not 2 of 2 — and the gate caught it rather than my reading of it:

```
[1/2] 6585468d… ok        likes=172 comments=20 images=6 tags=6 attempts=1 bytes=370138 billed=note-fetched
[2/2] 68f097b3… parse_failed/missing_fields:publishedAt,author,content  attempts=2 bytes=670499 free
```

Note 1 recovered field-for-field identical to the 11-02 control. Note 2 hit a
*different* problem: `diagnostics.stateParseFailures` was **0**, so the JSON parsed
fine — the page simply had no note in it. Captured and dissected
(`tests/fixtures/note-rednote-stub-68f097b3.html`):

- `noteDetailMap[id]` is present with keys `["comments","currentTime","note"]`
- **`note` is an empty object — zero keys**
- the only state subtree containing the noteId is **729 bytes**; the data is
  nowhere else in the 335 KB literal
- the page names its own cause: `state.note.serverRequestInfo` is
  `{state:"fail", errorCode:"aborted", errMsg:"{\"name\":\"HTTPClientError\",\"code\":\"aborted\"}"}`
  where the full variant reads `{state:"success", errorCode:0}`
- `global.isCrawlerRequest` and `isSearchEngineCrawlerRequest` are **false in both
  variants**, so this is not a crawler block and not our fingerprint — it is
  Xiaohongshu's own SSR fetch aborting

Measured rate: **3 stub pages in 27 draws (~11%)**, datacenter and residential
alike. Nothing can recover a stub, so the only remedy is another draw.

**Fix:** classify it as `server_state_fetch_failed:<errorCode>` — read off the
platform's own signal, only when the parse would fail anyway, so a page that
claims `fail` but still carries a readable note is still delivered. It gets its
own retry budget, `MAX_SERVER_STATE_RETRIES = 3` (four draws): at ~11%, two draws
leave ~1.2% of notes undelivered, which is exactly what the acceptance run hit,
and four leave ~0.015%. A genuine `missing_fields` page shape keeps the old single
retry, because redrawing a permanently-moved field four times is just spend.

**Verification:** 205/205 offline (was 184; +21). The headline test asserts the two
page variants of note `6585468d000000000503bb1f` — captured nine days apart —
deliver **field-for-field identical** results, and the stub fixture pins the empty
note object and the aborted `serverRequestInfo` verbatim. Six mutation controls,
each restored byte-identical:

| Mutation | Tests reddened |
| --- | --- |
| revert to the 0.1.9 blind `String.replace` | 6 |
| make the normaliser string-blind | 2 (exactly the string-safety pair) |
| drop the terminal-verdict guard on `stateParseFailures` | 1 |
| `??=` → `=` on `firstStateParseFailure` | 1 |
| drop the `serverRequestInfo` classification | 4 |
| `MAX_SERVER_STATE_RETRIES` 3 → 1 | 2 (exactly the four-draw pair) |

**Cost:** the rednote page is 370 KB against the old 83 KB, and a stub note now
costs up to four draws instead of two. Datacenter proxy transfer is unmetered on
this plan, so **COGS is unchanged and no price moved**; the added latency is
\~7 s per extra draw, inside the existing deadline guard.

**Not touched:** `pricingInfos`, `title`/`seoTitle`/`seoDescription`/`description`,
`exampleRunInput`, the input schema, and the billing semantics — a `parse_failed`
row was and still is free, and the fuse still counts it as wall-class.

### 0.1.9 — 2026-10-30

#### The six-tier subscription ladder went live

No `src/` behaviour change. `pricingInfos` record #2 was appended (append-only;
record #1 is echoed back untouched, `createdAt` included). Every paid tier is a
discount off the FREE tier, so this is a price **decrease** and took effect at
once: the record's `startedAt` (2026-10-30T06:31:32Z) *is* the effective time, and
the actor-level `notifiedAboutFutureChangeAt` — the field that would hold a pending
14-day notice — came back absent. The platform did stamp
`notifiedAboutChangeAt = 2026-10-30T07:00:28Z` on the new record ~28 min later,
the same instant it stamped on the other two Actors in this batch, which reads as a
periodic notification job. "No notification window" is supported; "no notification
was sent" is not. Existing users being told the price went **down** is benign.

| Event | FREE | BRONZE | SILVER | GOLD | PLATINUM | DIAMOND |
| --- | --- | --- | --- | --- | --- | --- |
| `note-fetched` | $0.005 | $0.0045 | $0.004 | $0.0035 | $0.0035 | $0.0035 |
| `note-translated` | $0.004 | $0.0036 | $0.0032 | $0.0028 | $0.0028 | $0.0028 |

**The FREE column is byte-identical to the prices before this change**, and
`cloud-tests/apply-tier-pricing.mjs` refuses to run at all if it is not — the red
line is enforced, not promised. Readback after the PUT: **16/16 assertions PASS**
(1 → 2 records).

Both events run the family's full ladder. The worst rung still clears measured cost
comfortably, so no cap was needed here (unlike `amazon-reviews-snapshot`'s
`ratings`):

- `note-fetched` at GOLD $0.0035 → our 80% share $0.0028 against $0.000502
  measured per note (run `qyOpzsm5FE24Pg1We`, S1 residential, 10/10 delivered,
  $0.005020 — the *dearer* exit; datacenter measured $0.000100–$0.000161) =
  **82.1% margin**.
- `note-translated` at GOLD $0.0028 → our share $0.00224 against $0.000959 per
  note ($0.00081 DeepSeek peak, measured on `yKTUtPpwyEpmRRxao` at 589 in + 558
  out tokens per note, plus $0.000149 platform) = **57.2% margin**. The DeepSeek
  bill is external and does not appear in `usageTotalUsd`, so it is added by hand
  here — reading the platform's cost field alone would overstate this margin.

No `run-base-fee` was added. This Actor has none and deliberately gets none: a
single-note lookup with no start fee is a legitimate shape (ops handbook A-008,
owner ruling 2026-10-30). Nothing outside the two events above was touched.

#### Disclosure and the drift guard

README now publishes all six tiers for both events and marks the figures in its
cost examples as FREE-tier prices ("a translated note is $0.009" was true but
unqualified, and is now qualified). `tests/pricing-tiers.test.js` pins three
things together off `cloud-tests/pricing-tiers.json`: the ladder, `LIST_PRICES` in
`src/billing.js`, and the README table. `LIST_PRICES` is only the offline fallback
(`readPricing` overwrites it with the prices the run was issued), so drift does not
mischarge anyone — it makes every local run, cost estimate and offline test lie by
exactly the drift, which is how a wrong number reaches a README six weeks later.
Mutation-checked on the sibling repo: moving `LIST_PRICES` by one part in a
thousand fails 3 tests, moving a README rung fails 1.

#### Two landmines found and closed in `cloud-tests/deploy.mjs`

1. **`--repricing` would have flattened the ladder.** It builds its new record
   from the flat `PRICING_SEED` and decides whether to append by comparing
   `eventPriceUsd`. A tiered live record has no `eventPriceUsd` at all, so the
   comparison reads "differs" and the flag appends a flat record over the ladder —
   silently repricing every paid subscriber back to list. Now refuses and points
   at `apply-tier-pricing.mjs`.
2. **The metadata PUT was unconditional.** It pushed `title`, `description`,
   `seoTitle`, `seoDescription`, `categories`, `defaultRunOptions` and
   `exampleRunInput` from the local manifest on every run. For this Actor local and
   live happened to agree on all six, but that is luck, not a guarantee — the same
   block on `amazon-reviews-snapshot` was carrying a stale `seoTitle` that would
   have undone an owner re-rule. The PUT is now behind `--meta`, and without it the
   script reports live-vs-local drift instead of writing.

Also learned the hard way on the sibling repo and now asserted locally before the
call: **`reasonForChange` is capped at 250 characters** (HTTP 400
`checkAndSanitizePricingInfosModifier[new_record]: reasonForChange must be at most
250 characters long`). Nothing is written by a rejected attempt — the modifier
validates before it mutates.

Tests 177 → **184** (all green).

### 0.1.8 — 2026-10-27

#### P0 — the platform started redirecting overseas exits to `rednote.com`, and every note came back empty

The daily canary caught a total loss of delivery: run `PNo08Fiz56bFii6Wn`
(2026-10-27T09:10Z, build 0.1.7) finished **SUCCEEDED** having delivered
**0 of 2** notes — both `parse_failed`, 316 bytes between them (158 per note,
i.e. a redirect stub, not a page), `chargedUsd 0`, and a `failReason` of
`unknown_redirect:www.rednote.com/explore/<noteId>`. The identical input on the
identical build had delivered 4 of 4 sixteen hours earlier
(`krpIFY1Tzw4MsxAaM`, 2026-10-26T17:13Z), and the canary itself had delivered
2 of 2 with 168,571 bytes that morning (`Ya03w5k7ynws6l63K`, build 0.1.6). So
this is not a code regression: **somewhere in that window Xiaohongshu began
answering an overseas exit's request for `www.xiaohongshu.com/explore/<id>` with
a 302 to the international mirror `www.rednote.com`.** A Chinese exit still gets
a plain `200` with `window.__INITIAL_STATE__` (measured from the dev machine the
same day: 82,840 bytes), which is why nothing in the local corpus hinted at it —
every fixture was captured on a CN exit.

`isBenignRedirect()` required `target.host === 'www.xiaohongshu.com'`, so the
mirror redirect fell through to the catch-all `unknown_redirect` branch of
`classifyResponse()` — the branch reserved for shapes we have not verified. The
classification was *defensible* and the outcome was still a buyer with zero rows:
the Actor is published, and Apify's datacenter exits are overseas, so from the
moment the platform flipped, every run delivered nothing. Billing behaved
correctly throughout (`parse_failed` rows are free, `$0` charged), which is why
the run reported success.

Fix: replace the single-host equality with an exported `NOTE_HOSTS` allowlist —
`www.xiaohongshu.com`, `xiaohongshu.com`, `www.rednote.com`, `rednote.com` — and
use the same list in `input.js` for `normalizeNoteRef()`, so a buyer who pastes a
link they copied out of that redirect is no longer rejected as
`unsupported_host`. The request URL stays `www.xiaohongshu.com`, because a CN
exit still serves it directly; one request shape now works on both.

The allowlist stays an allowlist. `fetchNotePage()` runs through the *buyer's*
proxy session, so following an arbitrary `Location` would let a poisoned response
walk that session to a third party — three new tests pin that a look-alike host
(`rednote.com.evil.example`, `www.rednote.co`, `notrednote.com`) is refused, that
a wall / dead-note / non-note path on the mirror is refused exactly as it is on
the primary host, and that an unrecognised off-host redirect still classifies as
`unknown_redirect` rather than being followed.

`.actor/actor.json` categories were synced to the live value
(`SOCIAL_MEDIA`, `AUTOMATION`): the deploy script PUTs categories from the
manifest, and the manifest still carried a third one that had been dropped at
publish time, so the next deploy would have silently reverted a Store setting.

Tests 175 → **177**. Whether the mirror actually serves the anonymous SSR page
is a cloud question, not a local one — the verification run is recorded in
`cloud-tests/evidence/`. If `rednote.com` answers with a client-rendered shell
instead, the classifier now says so precisely (`no_initial_state:<n>chars`) and
the fallback is an exit that still reaches the primary host, not another change
to the redirect rule.

#### Monitoring gap that let it sit silent

The canary *did* fire and *did* fail — nobody was told. `canary-auditor`'s
`src/checks.js` gained the `xhs-note-tracker-daily-canary` assertion on
2026-10-26, but the deployed auditor was still build 0.1.9 from 2026-10-24, so
its 10:15 run that day emitted 11 rows and no row for this Actor. The assertion
that exists only in a working tree asserts nothing. Deployed alongside this
build (separate repository).

### 0.1.7 — 2026-10-26

Answering the gatekeeper's independent pre-launch acceptance report
(`20261026_0.1.6上架前独立验收报告.md`, verdict **NO-GO**): one P0, four P1 and
four P2, all fixed in this build. Tests 168 → **175**.

#### P0 — a counter the platform withheld was delivered as `0`

`buildRow` computed all five counters as `Number(p?.X) || 0`. `Number(null)` is
`0`, so the only layer that still laundered "unknown" into "zero" was the row the
buyer actually receives: `parseCount` in `xhs-parse.js` returns `null` for a
withheld counter and `track.js` stores `null`, both correct. The consequences were
not cosmetic —

- `dataset_schema.json` declares all five as `["integer","null"]` and documents
  "never as 0", and the README's Real-data example shows nulls. The delivered row
  contradicted the published contract on every affected note.
- Growth tracking is this Actor's only differentiator, and `niceCount` is
  unpublished on ~49 of 50 notes. A buyer doing their own second-order analysis
  over the dataset or a CSV export would see a phantom `0 → 152` spike on the first
  readable reading. The Actor's own `track.delta` was right (the KV holds null) —
  **the data it handed over was wrong**, which is the worse way round.
- The gatekeeper reproduced 117 violations across 8 of their own runs and, scanning
  our datasets independently, found 179 ok rows carrying
  `counters_not_published:X` of which **zero** had the field null.

Now `ok && Number.isFinite(p[name]) ? p[name] : null` — literally the test
`track.js` already applied, so the delivered row and the history record can no
longer disagree. A real `0` still delivers as `0`; telling the two apart is the
whole point.

**Why 168 green tests missed it:** every fixture fed a real number. Two tests now
feed `null`, and one encodes the gatekeeper's acceptance assertion directly — for
each field named in `counters_not_published:…`, the row's value must be `null`.

#### P1 — four ledger/robustness defects

1. **The RUN_SUMMARY latch was set after the await it was meant to protect.** A
   final write can take ~31 s (15 s timeout plus one retry) and `persistingPartial`
   only serialised checkpoints against each other, so a persistState tick inside
   that window could land *after* the finished report and republish a successful
   run as `partial: true, persistReason: "persistState"`. The latch and the
   in-flight guard are now both taken **before** the await, and released again if
   the write fails (`clearRunSummaryFinal`) so a later tick can still leave a
   readable ledger. The wiring assertion was also rewritten: it compared
   *positions* in the source instead of matching one literal line, which the
   gatekeeper rightly flagged as passing vacuously after any refactor.
2. **A run killed inside its first ~60 s had charged and left no ledger** — the
   checkpoint was driven only by the ~60 s persistState tick. Now flushed on the
   first charge and every `FLUSH_EVERY_CHARGES = 10` charged rows thereafter
   (≤100 extra KV writes at `maxNotes: 1000`). Same root cause as the eBay bridge's
   N-3 and `amazon-reviews-snapshot`'s S-2.
3. **The translate phase ignored the deadline table.** One note's worst case is
   2 × 30 s of fetching plus 2 × 120 s of DeepSeek ≈ 300 s against a 48 s finish
   reserve, so a single note could overrun the soft window by ~4 minutes into the
   platform's SIGKILL — which is exactly how defect 2 gets triggered in practice.
   Translation is now refused when fewer than `TRANSLATE_DEADLINE_RESERVE_MS`
   (240 s) remain: the Chinese row is still delivered and still billed, the
   translation is **not** billed, and the count lands in the new
   `translate.skippedDeadline` with a line in `humanReadableReason`.
4. **A failed track history write was half-silent.** It logged once and counted in
   `RUN_SUMMARY.track.writeErrors`, but did not touch `partial`, was not named in
   `humanReadableReason`, and was absent from `OUTPUT` — so a schedule integration
   that reads only `OUTPUT` could never see that a paid feature had
   under-delivered. All three are now wired, and `partial` is `true` whenever
   `writeErrors > 0`. The run is deliberately **not** failed: the rows were
   delivered and billed correctly, and `Actor.fail()` would put a good delivery at
   risk to signal a bookkeeping problem.

#### P2 — four smaller ones

- **`noteId` was taken from the page, not from the request.** `pickNote` falls back
  to the first key of `noteDetailMap` and trusts the page's own id, so a page
  serving some other note would have been billed as `note-fetched` **and**
  snapshotted into that other note's history key — growth attributed to a note
  nobody asked for. `fetchNote` now asserts the served id equals the requested one;
  a mismatch is wall-class `parse_failed` (so it rotates the session and retries),
  is free, and the row keeps the requested id.
- **`minMemoryMbytes` 512 → 256.** Measured peak is 60–65 MB with no
  whole-list residency, so 512 was a floor that blocked a legitimate cheaper tier.
  The *default* stays at 512 until a 256 MB cloud run is verified; only the floor
  moved, so a buyer can now choose it.
- **`invalidInputs` echoed up to 200 raw characters of whatever the buyer pasted**
  into their own key-value store, where it outlives the run. Now truncated to 120
  characters with every query value and any recognisable credential shape
  (`sk-`, `apify_api_`, `ghp_`, `github_pat_`, `xox*`, `AKIA`, userinfo in a URL)
  redacted. The note id lives in the path, which is kept, so the field still tells
  you which line failed.
- **The translate run-time claim was wrong in the buyer's favour-by-omission
  direction**: "roughly doubles run time" for a serialised per-note API call that
  measures 3–5×. Corrected in `README.md` and the `translate` field description,
  together with what now happens at the window's end.

#### Disclosure added (release condition 2)

`README.md` and the `noteUrls` description now say plainly: **paste the full link
including its `xsec_token`.** For a note published in the last few months the token
is the only thing that makes it readable anonymously — the gatekeeper measured
13/14 delivered with tokens and a `/404` + `error_code 300031` for the same 14 with
tokens stripped, and confirmed a token is bound one-to-one to its own note id.
Without this the failure surfaces to a buyer as "low delivery rate" and reads as a
broken Actor. `/search_result` remains unreachable anonymously, which is why there
is no keyword-search mode.

#### Cloud verification of this build (7 arms, all green)

Build `0.1.7` = `lOg8un5h4HK8wzDcq`. Full readings and run ids live in
`cloud-tests/CASES.md`; the headlines:

- **The P0 acceptance arm** (`qZcBGK538PZ6z6pIq`, the same 50 notes): the
  gatekeeper's criterion returns **0 violations**, and so does its converse. On
  0.1.6 the same audit found 117 across 8 of their runs and 179 in ours. 49/50
  delivered, `chargedUsd 0.245` = 49 × $0.005 with `intendedEvents ==
  chargedEvents == chargedEventCounts`, peak memory **67 MB**.
- **The fresh-corpus arm** (`cXMUN2DSajRySMsJo`, the gatekeeper's own input file
  copied byte-for-byte): **13/14 delivered**, the same 14th note `private`,
  **0 P0 violations where their 0.1.6 arm had 13**. `niceCount` was withheld on
  **13 of 13** fresh notes, so on a real buyer's link list the old bug was not an
  edge case — it was every row.
- **Track, both directions** (`i4U555XB6rGA8kdw3` then `OGVCT4XghK6NUWBOW`,
  history cleared first): `previousFound 0 → 10`, `firstSeen 10 → 0`,
  `snapshotsWritten 10`, **`writeErrors 0`**, `readErrors 0`. The first run wrote
  **15** KV records against **13** for the identical 0.1.6 arm — the extra two are
  the new first-charge and every-10-charges ledger flushes, which is platform-side
  proof rather than source-side.
- **A hard kill under 45 s** (`pTb2YlzkKO7t6k3RN`, ABORTED at 33.97 s): the ledger
  **exists**, and `chargedUsd 0.05` with `{note-fetched: 10}` matches the
  platform's settled `chargedEventCounts` event for event. Attribution kept honest:
  `persistReason` is `charged-flush`, so what this proves is the flush, not the
  SIGTERM path.
- **The lowered memory floor** (`EDOfNhNcKt6yObZuB`): the platform accepted
  **256 MB**, 5/5 delivered, peak **63.2 MB**. `defaultRunOptions.memoryMbytes`
  stays at 512 until a large batch has been run at 256 — a floor measured on 5
  notes is not a floor measured on 1 000.
- **The bare-id control** (`LXHgURjQ405TFS7Ej`): 14 stripped links → 14/14
  `deleted / error_code_300031`, $0 charged, **zero per-note differences** against
  the gatekeeper's 0.1.6 arm.

Two things fell out of the fresh arms that are worth more than the regression they
were run for. **`xsec_token` lifetime is at least 13.64 h** — the gatekeeper
harvested those links at ~08:15 local and this build consumed the same links at
\~22:00 and still delivered 13/14, so a buyer's saved link survives the day. And
because the two arms sit 13.64 h apart, comparing them note by note gives the
first real measurement of the differentiator: **9 of 13 fresh notes moved**
(`+96` likes, `+22` collects, `+103` comments, `+30` shares), one gained **+100
comments** in that window, and one reported **`collectedCount: -1`** — the
un-clamped negative passthrough in `computeTrack()` firing on real data for the
first time. The only *systematic* difference between the two arms was `niceCount`
going `0 → null` on all 13 rows, which is exactly the P0 fix and nothing else.

#### Not changed here

Pricing mechanism (flat vs the six-tier subscription discounts the bridge and
search Actors use) is an owner decision, not a code one, and is unchanged. This
repository still has no `.git`; that needs an explicit authorisation per repo.

**One documentation change is deliberately queued instead of shipped:** the README
should say that an `xsec_token` is still good **at least 13.64 h** after it was
copied (measured above), because "paste the full link" currently reads as if the
link expires in your hands. `README.md` is in `deploy.mjs`'s upload set, so that
sentence costs a build — and 0.1.7 is the build the gatekeeper is retesting right
now, so cutting a new one mid-review would invalidate the version under test. It
goes out with whatever the next change is.

### 0.1.0 — 2026-10-26

First implementation, built from `strategy/2026-10-25_小红书笔记追踪器_PRD.md` v2.1.

#### What it does

- Anonymous, HTTP-only snapshot of a public Xiaohongshu note: title, body, the
  four engagement counters, hashtags (names plus the platform's own ids), images,
  author and timestamps. No login, no cookies, no signature forgery, no browser.
- `mode: "track"` compares each note against the previous run and adds
  `track.previous` / `track.delta` / `track.intervalHours`, plus flat
  `deltaLikes` / `deltaCollects` / `deltaComments` / `deltaShares` /
  `trackIntervalHours` columns so the deltas survive a CSV export.
- `translate: true` adds `titleEn` / `descEn` / `tagsEn` via DeepSeek, charged as
  a separate event after the row carrying them has landed.
- Pay per event, no startup fee, and a note that could not be read is free.

#### Discipline carried over from the rest of the portfolio

- **Atomic delivery + billing**: one `pushData(row, eventName)` call. The PRD's
  "pushData, then charge" wording was rejected in review (v2.1 §0.1 B3) because two
  calls can bill a row that never landed.
- **Fuse counts walls only**: `nextFuseCount` is an exported pure function;
  `deleted` and `private` are transparent to it, so a watch list that opens with
  removed notes still runs through to the live ones behind them.
- **Completeness identity**: `delivered.rows + sum(skippedBy) ===
  requested.dedupedItems`, verified before exit; a mismatch fails the run.
- **Price-relative assertions**: `LIST_PRICES` is only the local fallback,
  `readPricing` prefers the price the run was actually issued, and the tests fake
  an issued price deliberately different from it. No test or doc hard-codes a
  dollar figure that could go stale on the next re-rule.
- **No silent under-delivery**: a 200 with a hole in it is `parse_failed` with
  `parseWarning` naming the field, never a green row of nulls.

#### Where the build corrected the PRD

Recorded in full in PRD v2.1 §0.1; the three that changed code:

- **B2 (track tenancy) — the PRD's premise was wrong.** It assumed the named KV
  store belongs to the Actor owner and is shared by all customers, and prescribed
  `note:{APIFY_USER_ID}:{noteId}`. An unqualified named store resolves inside the
  account of whoever started the run: Apify's own storage docs describe
  `username~store-name` as the form for reaching a store that "belongs to a
  different account", and `1688-product-scraper/src/token-cache.js` states it
  outright ("their SDK can only see stores in their own account" — the reason the
  shared warm-token cache had to go over REST with an injected token). So the key
  is one bare note id and the store is namespaced
  (`crawleast-xhs-note-tracker-history`) instead, because any other Actor the same
  customer runs can open a store by name and a generic name is a live collision
  hazard. Two consequences are stated in the README rather than hidden: the
  history is the customer's data, and it is not a moat. (As first built the key was
  `note:{noteId}`; the colon turned out to be invalid on the platform and the
  separator is a dot from build 0.1.5 — see below.)
- **B6 (translation batching) — deliberately not implemented.** PRD §7 asked for
  multi-note batches. Batching would hold up to eight fetched notes undelivered
  between the API call and the push, and a crash in that window loses rows the
  customer's watch list expects. The token saving measures ~1.6% of note revenue;
  the delivery guarantee is worth more. `translateNotes` is still written to pack
  any list, and the caller passes one note at a time.
- **`edited` was removed after measurement.** The PRD treated
  `lastUpdateTime != time` as an edit signal. In the four real captures one note
  had `lastUpdateTime` **3.07 days before** `time` and another exactly **1 second
  after** it (publishing latency), and the note object carries no `edited` flag.
  The raw `updatedAt` is delivered with that caveat instead of a boolean that
  would be wrong most of the time.

#### Fixtures

`tests/fixtures/` holds six real anonymous captures plus two header dumps (a
dead-note 302 and an unavailable-note 302). The P0 probe never stored raw HTML,
so these are the only real samples in existence for this Actor and the parser
tests are pinned to them. See that directory's README for provenance, structure
findings and reproduction commands.

#### What the cloud phase found and fixed (2026-10-26, build 0.1.4)

Four defects that no offline test could have reached, because all four are
properties of the real platform rather than of our model of it. Each is now
pinned by a test built from the capture that exposed it.

- **The 302 classifier never ran in production.** `maxRedirects: 0` makes got v14
  throw `MaxRedirectsError` ("Redirected 0 times. Aborting.") even with
  `throwHttpErrors: false`, so every redirect — the platform's own verdict on a
  dead, private or walled note — arrived as an opaque
  `fetch_failed / transport`. That also made a dead note *wall-class*, feeding
  the fuse. Fixed with `followRedirect: false`, which returns the 3xx with its
  `Location` intact. Found by cloud run `fxdfuLLFimSxrJVJh` (50 notes, 1 row).
- **A third redirect shape, previously unknown.** A note the platform will not
  serve anonymously answers `302 → /explore?target_note_id=<id>&
  undertake_note_error=<doubly url-encoded 该内容暂时无法查看>`. Now classified
  `private` / `note_unavailable:<message>`: input-class, free, transparent to the
  fuse. The 302 body is 51,951 bytes of feed shell that *also* carries
  `window.__INITIAL_STATE__`, so status must be read before body — a body-first
  classifier would have delivered it as an `ok` row of nulls.
- **A note with no title is a real note.** Xiaohongshu publishes body-and-images
  notes; `title: ""` sat next to a 576-char body, 150 likes and 152 collects on
  note `68dbeba8000000000703ac0f`. The old required-field list threw that live
  note away as `parse_failed / missing_fields:title`. The required set is now
  publish time + author + at least one of title/body/images, and a delivered row
  can carry `parseWarning: "no_title"`.
- **A withheld counter is `null`, not `0`.** The platform publishes `""` for the
  counters it is not serving (`commentCount` and `niceCount` on that same note).
  `parseCount('')` and `toStored` both laundered that into `0`, which would have
  turned the first real reading into a phantom growth spike in track mode — the
  one failure this Actor's differentiator cannot survive. Now `null` end to end,
  with `counters_not_published:<names>` on the row and no delta for that counter.
- **A finished RUN_SUMMARY could be overwritten by a checkpoint.**
  `Actor.exit()` emits one final `persistState`, and the handler rewrote the
  completed report as a `partial: true` lower bound: run `yrrpPGvPgHcjPVlxr`
  published `partial: true, persistReason: "persistState"` for a 5/5 complete
  run. Whether the write lands before the container dies is a race, which is why
  earlier runs looked clean. Latched with `markRunSummaryFinal()` and a
  `shouldCheckpoint()` gate. **The same defect exists in
  `amazon-reviews-snapshot` and `ebay-to-1688-sourcing-bridge`, which share this
  code, and is fixed there too.**
- **Store metadata has undocumented length caps**, found by four consecutive 400s
  from `POST /acts`: `title` ≤ 63, `description` ≤ 300, `seoTitle` ≤ 60,
  `seoDescription` ≤ 200. Pinned in `tests/schema.test.js` so a listing rewrite
  fails the build instead of the deploy.

Measured on the 50-note re-run (`QYDBQroMGnykz3jzS`, build 0.1.4, datacenter US,
1500 ms pacing): **49/50 delivered**, the 50th correctly `private /
note_unavailable` and free, **one request per note**, zero `300017`, 83 KB per
note, 65 MB peak memory, 255 s, platform usage **$0.0079 for the batch**
(≈$0.00016 per note), $0.245 of PPE charges against it.

#### What the track double-run found (2026-10-26, builds 0.1.5–0.1.6)

- **Track mode wrote nothing at all, and looked healthy while doing it.** The
  history key was `note:<noteId>`. Apify validates record keys against
  `/^([a-zA-Z0-9!\-_.'()]{1,256})$/` (`@apify/consts`
  `KEY_VALUE_STORE_KEY_REGEX`) but crawlee only applies that check in
  `KeyValueStore.setValue` — `getValue` checks non-empty and nothing else, and the
  REST read of a key that cannot exist simply returns nothing. A colon therefore
  fails *asymmetrically*: all 10 writes threw while all 10 reads reported "never
  seen before". Cloud run C1 (`case-c1-track10-first`) delivered 10/10, billed
  10/10, logged a clean `Track: previous=0 firstSeen=10 written=0` INFO line, and
  wrote **0/10** snapshots — the growth deltas that are this Actor's whole
  differentiator would never have appeared for anyone. Fixed by making the
  separator a dot (`note.<noteId>`), and fixed twice over:
  - `createMemoryStore` now enforces the same rule with the same asymmetry. A
    stand-in that accepts any string is precisely how the colon survived 164
    offline tests, so the test double is now as strict as the thing it stands for.
  - The first write error logs at `error` level. The counter existed in
    `RUN_SUMMARY.track.writeErrors` and in `notes[]`, but a customer watching the
    console saw nothing; under-delivery of a paid feature must not be quiet.
- No migration is needed: because every write failed, no record in the old key
  shape exists in any account.
- **`partial: true` was reported for a run that had finished** (build 0.1.6). The
  flag was `trigger !== 'done' || skippedTotal > 0`, and `skippedTotal` counts
  `invalidInput`. Cloud case E (`Ij5NSUec00wQZsx47`, 1 good URL + 5 junk strings)
  therefore published `trigger: "done"` and `partial: true` side by side, with a
  reason line reading "5 of 6 notes were not fetched" — our phrasing of the
  buyer's typo as our shortfall. Every other skip bucket is work a re-run could
  do (raise `maxNotes`, raise the cap, split the list, wait out the wall); an
  unparseable entry gets the same verdict every time it is submitted. Now
  `unfinishedTotal`, which excludes `invalidInput`, drives the flag, while the
  completeness identity still counts all six inputs. The reason line names the
  real cause and says the entries were not charged, and when a resource stop and
  bad input happen together it reports both instead of dropping one.
  `UNFINISHED_SKIP_KEYS` is exported next to `SKIP_KEYS` with the reasoning, and
  `cloud-tests/cost-report.mjs` now audits the corrected rule across every case.

#### Not done yet (release gates, not code gaps)

- S2 (bare vs `xsec_token` coverage, plus the hard gate on whether `300031` can
  be a wall in disguise). The token arm needs a real share link: `xsecToken` is
  an empty string in the server-rendered page, so there is no anonymous source of
  tokens to test with.
- S3's 24 h re-test of the signed image links (first arm measured 10/10
  downloadable with no `Referer`; the frozen list is
  `cloud-tests/evidence/s3-image-urls-2026-10-25T18-17-22-124Z.json`).
- The zero-delivery fuse has never actually fired in the cloud. Case H ran 50
  notes unpaced and the platform served all of them, so the threshold is
  unexercised; it is covered offline only.
- The Actor is private. Publishing is the owner's button, not the agent's.
