fix(7736): #N in a body links to the record it names, not to a tag
CI & Build / TypeScript typecheck (push) Successful in 35s
CI & Build / Python lint (push) Successful in 2s
CI & Build / Plugin hooks (push) Successful in 14s
CI & Build / Python tests (push) Failing after 1m37s
CI & Build / integration (push) Successful in 2m11s
CI & Build / Build & push image (push) Skipped

A purely numeric #N is a record reference everywhere now. The tag
patterns (frontend utils/tags.ts, the editor decoration, the first-line
tag strip, tag autocomplete, backend utils/tags.py) leave digits alone,
so #3127 is no longer drawn as a tag chip linking to /notes?tag=3127.

- utils/recordRefs.ts links #N, milestone N and rule N in rendered
  markdown, with the same patterns and other-numbering word list as
  services/record_refs.py. A drift test reads the TS source and fails
  when the two differ.
- v-record-refs (directives/recordRefs.ts) asks POST
  /api/notes/resolve-refs once per body for what each id is. A link
  gets the route for its kind (task, lesson, snippet, note, milestone,
  rule) and its kind and title on hover. One the reader cannot open is
  drawn as a dead reference, and missing vs not shared read the same.
  Applied on every surface that renders markdown.
- /milestones/:id finds the project and opens its board at that
  milestone (?milestone= expands it, scrolls to it and focuses it).
- Backlinks include records that cite #N in a body or a work log,
  through readable_notes_clause instead of an owner-only filter, and
  route by kind. The graph draws #N citations as dashed reference edges.
- create_note, create_task and add_task_log say which forms link.

There were no numeric tags to clean up: tags are stored only from the
explicit field, and none of the 200 most used is numeric.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-22 14:15:15 -05:00
co-authored by Claude Opus 5.5
parent 6be44013bb
commit 38bc25a2b7
24 changed files with 846 additions and 48 deletions
+32
View File
@@ -6,6 +6,7 @@ from quart import Blueprint, jsonify, request
from grimoire.auth import login_required, get_current_user_id
from grimoire.routes.utils import not_found, parse_iso_date, parse_pagination
from grimoire.services import record_refs
from grimoire.services.access import can_write_note
from grimoire.services.notes import (
build_note_graph,
@@ -194,6 +195,37 @@ async def resolve_title_route():
return jsonify(note.to_dict())
@notes_bp.route("/resolve-refs", methods=["POST"])
@login_required
async def resolve_refs_route():
"""What the record references in a rendered body point at.
Body: {"notes": [ids], "milestones": [ids], "rules": [ids]}. Answers the
same three keys, each a map of id -> {title, kind fields}, holding only the
records the caller may read. An id left out of the answer is drawn as a
reference that leads nowhere. The web UI calls this once per rendered body
to give each `#N`, `milestone N` and `rule N` link its route and its title.
"""
uid = get_current_user_id()
data = await request.get_json(silent=True) or {}
spaces: dict[str, list[int]] = {}
for key in ("notes", "milestones", "rules"):
raw = data.get(key) or []
if not isinstance(raw, list):
return jsonify({"error": f"{key} must be a list of ids"}), 400
try:
spaces[key] = [int(i) for i in raw]
except (TypeError, ValueError):
return jsonify({"error": f"{key} must be a list of ids"}), 400
if sum(len(v) for v in spaces.values()) > record_refs.RESOLVE_LIMIT:
return jsonify({
"error": f"at most {record_refs.RESOLVE_LIMIT} references per call",
}), 400
resolved = await record_refs.resolve_refs(uid, **spaces)
# JSON object keys are strings; say so here rather than in every caller.
return jsonify({k: {str(i): v for i, v in m.items()} for k, m in resolved.items()})
@notes_bp.route("/duplicates", methods=["GET"])
@login_required
async def find_duplicate_records_route():