Skip to content

fix(user.js): resolve DP dormant code, extract shared helpers to a lib - #308

Draft
netravnen wants to merge 1 commit into
dev-nextfrom
fix/dp-lifecycle-triage
Draft

fix(user.js): resolve DP dormant code, extract shared helpers to a lib#308
netravnen wants to merge 1 commit into
dev-nextfrom
fix/dp-lifecycle-triage

Conversation

@netravnen

@netravnen netravnen commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

fix(user.js): resolve DP dormant code, extract shared helpers to a lib

Applies the ratified dp-dormant-clusters triage, reworked per review:
instead of deleting DP's reusable dormant code outright, the pieces
with planned cross-script use move to a new shared fragment,
lib/admincom-shared-helpers.js. For now only the DeskPro script
inlines it, alongside admincom-common.js; whether CP and FP include
it too is deliberately deferred until a concrete caller lands there,
so this commit leaves both untouched. Genuinely superseded or
abandoned code is still deleted (git history preserves it), planned
features are marked with the frozen @StaGeD grammar, and the staged
fetcher's latent bugs are fixed and pinned by a hook-driven test in
the same commit.

The new fragment carries both restored-from-deletion helpers and
live DP internals they depend on: formatSpeedLabel and
getTabSessionStorage (both restored and staged; CP keeps its
identical local getTabSessionStorage twin and is the intended adopter
once the fragment is included beyond DP), the editable-region
predicates (EDITABLE_CONTAINER_SELECTOR, isNodeInsideEditableRegion,
and the restored isAnchorInsideEditableRegion alias), the
IPV4_TEST_REGEX/IPV6_TEST_REGEX pair, getBestApiNetDataItem,
resolveEntityLegalName, and fetchAsnNetworkName -- DP's retired
ASN -> network-name resolver reworked for cross-script use with an
injectable fetchJson transport (the default is same-origin
fetchWithRetry, right for CP/FP if they adopt; cross-origin DeskPro
passes its GM-backed pdbFetch), shared "asn"-type cache persistence,
in-flight dedupe, and a transport-failure-is-not-cached rule. Lib
symbols with no caller yet carry @StaGeD wip markers.

Changes:

  • lib/admincom-shared-helpers.js: new shared fragment (see above)
  • peeringdb-deskpro-tools.src.js: delete the legacy ASN-name cache
    path (fetchAsnNetworkName's old form, asnNameCache, asnNameInFlight,
    getAsnNameCacheStorageKey, normalizeAsnForCache,
    getCachedAsnNameFromStorage, setCachedAsnNameInStorage) and the
    loose orphans (IX_SHORTCUT_ATTR, ACTION_EMOJI_IX, ensureIxShortcut,
    DUMMY_ORG_ID, attr constants, USER_CACHE_TTL_MS); local copies of
    everything now in the lib removed; the duplicate weaker
    IPV4_TOKEN_REGEX/IPV6_TOKEN_REGEX and the never-consumed
    subjectHinted/RN_SUBJECT_HINT_REGEX stay deleted; stage the
    IP-tooltip cluster, the ASN batch-fetch cluster, and classifyError
    (with the fetchNetixlanByIp bug fixes); add the new lib's @include
    marker and export its helpers via test hooks; bump to 1.7.12
  • tests/lib-shared-helpers.test.js: new; covers formatSpeedLabel,
    getTabSessionStorage, the editable-region predicates, and
    fetchAsnNetworkName's cache/dedupe/transport contract through the
    injectable fetchJson transport
  • tests/dp-netixlan-ip-cache.test.js: new; pins fetchNetixlanByIp's
    shared cache signatures, null-means-miss, and negative caching
  • tests/helpers/browser-shim.js: provide Node.ELEMENT_NODE/TEXT_NODE
    constants (vm contexts have JS intrinsics but no DOM globals, so
    isNodeInsideEditableRegion threw before its logic could run)
  • tests/dp-renumber-launcher.test.js: drop subjectHinted assertions
  • AGENTS.md: document the new fragment (and its DP-only inclusion)
    plus its test file
  • peeringdb-deskpro-tools.user.js regenerated; CP and FP are not
    touched by this commit

Security:

  • N/A (no new write paths; staged code remains unreachable in
    production until wired up)

Testing:

  • Full suite green from user.js/: 585 pass, 0 fail (1 opt-in live
    skip), including 20 new lib-shared-helpers cases
  • Non-vacuity: disabling the resolver's memory-cache read turned the
    two cache-counting cases red; restored, green
  • fetchNetixlanByIp non-vacuity as before: the old
    cached !== undefined miss-check turns its cases red
  • build --check clean; node --check clean on all three .user.js

Backwards Compatibility:

  • getBestApiNetDataItem, resolveEntityLegalName, the TEST regexes and
    the editable-region check keep their exact behavior -- they only
    moved homes; all existing tests pass unmodified
  • classifyError keeps every previously-present key/value per branch;
    collectRenumberCandidates' subjectHinted field is removed (its only
    consumer never read it)
  • CP and FP ship no change at all in this commit
  • No live user-facing behavior changes

Assisted-by: Claude:claude-opus-5
Assisted-by: Claude:claude-fable-5


Stack created with GitHub Stacks CLIGive Feedback 💬

@netravnen
netravnen force-pushed the fix/dp-lifecycle-triage branch from 43753de to 550ac12 Compare August 20, 2026 14:02
Base automatically changed from chore/strip-stock-ai-tags to dev-next August 20, 2026 19:37
@netravnen
netravnen force-pushed the fix/dp-lifecycle-triage branch 2 times, most recently from 51297e2 to 642194a Compare August 20, 2026 20:01
@netravnen netravnen changed the title fix(dp): resolve dormant code per lifecycle triage fix(user.js): resolve DP dormant code, extract shared helpers to a lib Aug 20, 2026
@netravnen
netravnen force-pushed the fix/dp-lifecycle-triage branch from 642194a to c2bcb38 Compare August 20, 2026 20:14
Applies the ratified dp-dormant-clusters triage, reworked per review:
instead of deleting DP's reusable dormant code outright, the pieces
with planned cross-script use move to a new shared fragment,
lib/admincom-shared-helpers.js. For now only the DeskPro script
inlines it, alongside admincom-common.js; whether CP and FP include
it too is deliberately deferred until a concrete caller lands there,
so this commit leaves both untouched. Genuinely superseded or
abandoned code is still deleted (git history preserves it), planned
features are marked with the frozen @StaGeD grammar, and the staged
fetcher's latent bugs are fixed and pinned by a hook-driven test in
the same commit.

The new fragment carries both restored-from-deletion helpers and
live DP internals they depend on: formatSpeedLabel and
getTabSessionStorage (both restored and staged; CP keeps its
identical local getTabSessionStorage twin and is the intended adopter
once the fragment is included beyond DP), the editable-region
predicates (EDITABLE_CONTAINER_SELECTOR, isNodeInsideEditableRegion,
and the restored isAnchorInsideEditableRegion alias), the
IPV4_TEST_REGEX/IPV6_TEST_REGEX pair, getBestApiNetDataItem,
resolveEntityLegalName, and fetchAsnNetworkName -- DP's retired
ASN -> network-name resolver reworked for cross-script use with an
injectable fetchJson transport (the default is same-origin
fetchWithRetry, right for CP/FP if they adopt; cross-origin DeskPro
passes its GM-backed pdbFetch), shared "asn"-type cache persistence,
in-flight dedupe, and a transport-failure-is-not-cached rule. Lib
symbols with no caller yet carry @StaGeD wip markers.

Changes:
- lib/admincom-shared-helpers.js: new shared fragment (see above)
- peeringdb-deskpro-tools.src.js: delete the legacy ASN-name cache
  path (fetchAsnNetworkName's old form, asnNameCache, asnNameInFlight,
  getAsnNameCacheStorageKey, normalizeAsnForCache,
  getCachedAsnNameFromStorage, setCachedAsnNameInStorage) and the
  loose orphans (IX_SHORTCUT_ATTR, ACTION_EMOJI_IX, ensureIxShortcut,
  DUMMY_ORG_ID, attr constants, USER_CACHE_TTL_MS); local copies of
  everything now in the lib removed; the duplicate weaker
  IPV4_TOKEN_REGEX/IPV6_TOKEN_REGEX and the never-consumed
  subjectHinted/RN_SUBJECT_HINT_REGEX stay deleted; stage the
  IP-tooltip cluster, the ASN batch-fetch cluster, and classifyError
  (with the fetchNetixlanByIp bug fixes); add the new lib's @include
  marker and export its helpers via test hooks; bump to 1.7.12
- tests/lib-shared-helpers.test.js: new; covers formatSpeedLabel,
  getTabSessionStorage, the editable-region predicates, and
  fetchAsnNetworkName's cache/dedupe/transport contract through the
  injectable fetchJson transport
- tests/dp-netixlan-ip-cache.test.js: new; pins fetchNetixlanByIp's
  shared cache signatures, null-means-miss, and negative caching
- tests/helpers/browser-shim.js: provide Node.ELEMENT_NODE/TEXT_NODE
  constants (vm contexts have JS intrinsics but no DOM globals, so
  isNodeInsideEditableRegion threw before its logic could run)
- tests/dp-renumber-launcher.test.js: drop subjectHinted assertions
- AGENTS.md: document the new fragment (and its DP-only inclusion)
  plus its test file
- peeringdb-deskpro-tools.user.js regenerated; CP and FP are not
  touched by this commit

Security:
- N/A (no new write paths; staged code remains unreachable in
  production until wired up)

Testing:
- Full suite green from user.js/: 585 pass, 0 fail (1 opt-in live
  skip), including 20 new lib-shared-helpers cases
- Non-vacuity: disabling the resolver's memory-cache read turned the
  two cache-counting cases red; restored, green
- fetchNetixlanByIp non-vacuity as before: the old
  `cached !== undefined` miss-check turns its cases red
- build --check clean; node --check clean on all three .user.js

Backwards Compatibility:
- getBestApiNetDataItem, resolveEntityLegalName, the TEST regexes and
  the editable-region check keep their exact behavior -- they only
  moved homes; all existing tests pass unmodified
- classifyError keeps every previously-present key/value per branch;
  collectRenumberCandidates' subjectHinted field is removed (its only
  consumer never read it)
- CP and FP ship no change at all in this commit
- No live user-facing behavior changes

Assisted-by: Claude:claude-opus-5
Assisted-by: Claude:claude-fable-5
@netravnen
netravnen force-pushed the fix/dp-lifecycle-triage branch from c2bcb38 to 01af1fd Compare August 20, 2026 20:40
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.

1 participant