Skip to content

okf: fix concept-graph link resolution, reserved filenames, and payload escaping - #262

Open
ishita199615 wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
ishita199615:fix/viewer-graph-correctness
Open

okf: fix concept-graph link resolution, reserved filenames, and payload escaping#262
ishita199615 wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
ishita199615:fix/viewer-graph-correctness

Conversation

@ishita199615

Copy link
Copy Markdown

While using the OKF viewer I noticed it drops the spec-recommended /-style
links — the shipped acme_retail bundle renders only 6 of its 14 edges, with
both policy docs floating disconnected. Digging in turned up three more issues:
the reserved log.md gets drawn as a concept node, a </script> anywhere in
bundle content blanks the whole viewer (and lets the content execute as
markup), and a timestamped stale_after crashes visualize with a
TypeError.

This PR fixes all four, with six regression tests (suite goes 39 → 45, passing
on Python 3.11–3.13) and a small SPEC §6.1 note reconciling the two link forms
with the producer prompt — happy to split that spec edit out if you'd prefer.
No behaviour change for bundles that only use relative links. CLA signed.

…ad escaping

The bundle viewer dropped every bundle-absolute link, treated the reserved
`log.md` as a concept, and embedded its JSON payload unescaped. Fixes:

* `_extract_links` now resolves `/`-prefixed targets against the bundle
  root (SPEC §6.1) instead of skipping them as external. `viz.js` already
  treated this form as internal, so the Python and JS halves disagreed.
  On the shipped `acme_retail` bundle this restores 8 of 14 edges.

* `index.md` and `log.md` are now a single shared `RESERVED_FILENAMES`
  set (SPEC §3.1), honoured by both the viewer and the index generator.
  Previously `log.md` rendered as a concept node and `regenerate_indexes`
  emitted a spurious "Log" section that drifted from the committed
  bundles.

* The embedded payload is escaped so bundle content cannot terminate the
  inline `<script>` element. A concept title containing `</script>` left
  `window.BUNDLE` undefined (blank viewer) and executed injected markup.

* `is_stale` normalizes a `datetime` to `date`. YAML parses an unquoted
  timestamp into `datetime`, which raised `TypeError` and aborted the
  whole `visualize` run.

Adds five regression tests, each verified to fail without the change, and
a non-normative SPEC §6.1 note reconciling the two link forms with the
producer prompt's GitHub-rendering guidance.
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