Skip to content

v0.42.31.0 feat(links): open link_source provenance + link-add/link-rm/link-sources (#1941)#1957

Merged
garrytan merged 7 commits into
masterfrom
garrytan/davis-v2
Jun 8, 2026
Merged

v0.42.31.0 feat(links): open link_source provenance + link-add/link-rm/link-sources (#1941)#1957
garrytan merged 7 commits into
masterfrom
garrytan/davis-v2

Conversation

@garrytan

@garrytan garrytan commented Jun 8, 2026

Copy link
Copy Markdown
Owner

What & why

Closes the two ergonomics gaps from #1941 that forced a typed-citation-graph edge-writer to live downstream of gbrain instead of as a gbrain command. Filed by a downstream agent building a citation-graph ingester.

Gap 1 — provenance + CLI. engine.addLink/removeLink already accepted linkType/linkSource, but the ops didn't expose them, and there was no link-add/link-rm command. Now gbrain link/unlink take --link-source/--link-type, with link-add/link-rm aliases, plus a new gbrain link-sources to discover provenances.

Gap 2 — closed allowlist. link_source was a closed IN(...) CHECK; a new provenance like citation-graph was rejected, so derivers stamped manual and lost the distinction from hand-entered edges. Now it's an open kebab-case format gate (^[a-z][a-z0-9]*(-[a-z0-9]+)*$, ≤64 chars) — no migration per deriver.

Changes

  • Migration v114 relaxes the link_source CHECK (3 inline schemas + migration). Postgres uses NOT VALID + VALIDATE (transaction:false); PGLite plain DROP+ADD. Existing built-ins all satisfy the regex, so the constraint swap never fails on existing data.
  • add_link/remove_link expose --link-source/--link-type. Op-layer guard rejects the reconciliation-managed built-ins (markdown/frontmatter/mentions/wikilink-resolved) and defaults omitted provenance to manual (was the misleading engine default markdown).
  • cliHints.aliases mechanism (collision-guarded at startup; alias-aware --help) registers link-add/link-rm; fixes a pre-existing --type--link-type help typo.
  • list_link_sources read op + listLinkSources({sourceId?,sourceIds?}) on both engines (deterministic order, federated-scope aware), added to the minion read allowlist.

Test plan

  • New test/link-source-namespaced-regex.test.ts: regex/length boundaries, upgrade-path constraint swap on existing data, op guard + manual default, remove_link filters, list_link_sources scalar+federated scoping, alias resolution/collision/help.
  • Updated parity, brain-allowlist, and the mentions-migration test (fixed the now-valid inferred assertion).
  • Local: typecheck clean; affected + merge-adjacent suites green (391 tests across the link/migration/op/cli/engine files); end-to-end CLI smoke (link-add → link-sources → guarded rejects → provenance-filtered link-rm). Full parallel suite runs in CI.

Reviews

  • /plan-eng-review (clean) + codex outside-voice on the plan: 13 findings, all absorbed (strict-kebab regex, 64-cap, managed-built-in guard, lock-friendly migration, federated scoping, deterministic order, doc/help fixes).
  • Adversarial pass on the implementation diff: Claude subagent + codex both clear — no correctness bugs in this change.

Also fixed: supervisor queue-singleton (follow-up to #1849)

The adversarial pass flagged two correctness bugs in the v0.42.29.0 supervisor-singleton work (src/core/minions/supervisor.ts). Fixed in this PR:

  • supervisorLockId keyed on a config-derived DB identity (:305), but the lock row already lives inside the target database. Two supervisors on the same physical DB via different-but-equivalent URLs (pooler vs direct port, host alias, trailing params) computed different ids and both acquired the "singleton" lock. Now keyed on the queue alone; the database half of the mutex is physical. Removed the now-dead currentDbIdentity().
  • Stranded pidfile (:501): the process.on('exit') cleanup listener was installed after the DB-lock acquire, so the LOCK_HELD early-exit left this process's pidfile behind to block the next start. The listener is now installed first.

Regression test pins the listener-before-lock ordering and the queue-only lock-id invariant; KEY_FILES.md and the v0.42.31.0 CHANGELOG updated.

garrytan and others added 7 commits June 7, 2026 17:55
…tion v114

Open link_source from a closed allowlist to a kebab-case format gate
(^[a-z][a-z0-9]*(-[a-z0-9]+)*$, char_length<=64) so external derivers
stamp their own provenance (e.g. citation-graph) without a per-deriver
migration. Migration v114: Postgres NOT VALID + VALIDATE (lock-friendly,
transaction:false); PGLite plain DROP+ADD. Updates the schema.sql +
engine provenance contract comments. (#1941)
…nk-sources

add_link/remove_link now accept --link-source/--link-type; add_link guards
the reconciliation-managed built-ins (markdown/frontmatter/mentions/
wikilink-resolved) and defaults omitted provenance to 'manual' (was the
misleading engine default 'markdown'). New cliHints.aliases mechanism with a
startup collision guard registers link-add/link-rm; printOpHelp shows the
invoked alias name. New list_link_sources read op + listLinkSources engine
method (both engines, {sourceId?,sourceIds?}, deterministic order) powers
`gbrain link-sources`, added to the minion read allowlist. (#1941)
Covers the v114 regex/length boundaries, upgrade-path constraint swap on
existing data, the managed-built-in op guard + manual default, remove_link
type/source filters, list_link_sources scoping (scalar + federated) and
PG/PGLite parity, and alias resolution/collision/help. Fixes the prior
'inferred'-rejection assertion (now valid kebab) in the mentions test. (#1941)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
KEY_FILES.md current-state updates for #1941: link_source now an open
kebab-case provenance (migration v114), the add_link/remove_link guard +
defaults, list_link_sources + listLinkSources, and cliHints.aliases.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…llow-up #1849)

Two correctness bugs in the v0.42.29.0 supervisor-singleton work, caught by
adversarial review:

- supervisorLockId mixed a config-derived DB identity into the key, but the
  lock row already lives inside the target database. Two supervisors on the
  same physical DB via different-but-equivalent URLs (pooler vs direct port,
  host alias, trailing params) computed different ids and BOTH acquired the
  "singleton" lock. Key on the queue alone; the database half of the mutex is
  physical. Removes the now-dead currentDbIdentity() from worker-registry.

- The pidfile-cleanup process.on('exit') listener was installed AFTER the
  DB-lock acquire, so the LOCK_HELD early-exit stranded the pidfile this
  process had just created. Install the listener first.

Regression test pins the listener-before-lock ordering; updates the lockId
test to the queue-only invariant; KEY_FILES updated to current state.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@garrytan garrytan merged commit f401d74 into master Jun 8, 2026
21 checks passed
mgunnin added a commit to mgunnin/gbrain that referenced this pull request Jun 8, 2026
* upstream/master:
  v0.42.32.0 fix(sync): coerce non-string frontmatter titles + bounded auto-skip failure ledger (garrytan#1939) (garrytan#1956)
  v0.42.31.0 feat(links): open link_source provenance + link-add/link-rm/link-sources (garrytan#1941) (garrytan#1957)
  feat(skills): add idea-lineage (garrytan#1830)

# Conflicts:
#	src/core/content-sanity.ts
#	src/core/markdown.ts
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