Commit Graph

6 Commits

Author SHA1 Message Date
peptiderepo
817690c1b6 fix(schema): rewrite sanitize_molecular_formula() with element-grammar (Option B)
Replace character-allowlist regex with an element-token grammar validator.
Strip control characters first, then extract the maximal leading run of
valid element tokens ([A-Z][a-z]?\d*) and group separators (()[]·.).

Fixes: 'C10H12\ninjection' now returns 'C10H12' (was 'C10H12injection').
New:   fully invalid inputs (e.g. '<script>alert(1)</script>') return ''.
Keep:  parenthesised formulas (e.g. 'C2H5(OH)') pass unchanged.

Unit tests expanded from 4 to 7 formula cases covering all five DoD
requirements plus whitespace-only edge case.

PHP not installable in sandbox; all 7 test inputs hand-traced
against the regex and confirmed correct via Python simulation.

Agent-Session: peptide-schema-backfill v0.6.0 formula-validator
2026-06-13 05:42:13 +00:00
peptiderepo
1880d1db1f fix(tests): guard error_log/wp_json_encode stubs + document idempotency limitation
- tests/unit/test-migration-0004.php: wrap error_log() stub in
  function_exists() guard -- prevents PHP fatal redeclaration on
  PHP Lint (8.1/8.2/8.3) which runs php -l on all .php files.

- tests/bootstrap.php: update wp_json_encode stub to accept
  int $flags = 0 second arg (matches production call signature
  wp_json_encode($clean, JSON_UNESCAPED_UNICODE)); guard with
  function_exists().

- class-pr-core-migration-0004-backfill-peptide-meta.php: add
  code comment near idempotency check documenting the all-or-nothing
  limitation (post with legitimately empty aliases will re-run).

- CONVENTIONS.md: one-line note under migration conventions item 5
  documenting the idempotency caveat.

- CHANGELOG.md: add Fixed section under v0.6.0 for CI/test-stub fix.

Agent-Session: peptide-schema-backfill v0.6.0 P1 fix
2026-06-13 05:24:04 +00:00
peptiderepo
1e5999e663 feat(schema): v0.6.0 — PSA backfill migration + Yoast-integrated Drug/MedicalWebPage/FAQ schema
Piece 1 — Backfill migration 0004: copies PSA psa_molecular_formula/weight/aliases
into PR Core _pr_* meta. Idempotent + re-runnable. PubChem REST fallback for 4
posts missing PSA data (MAX_RETRIES=3, exp backoff). All PSA values UNTRUSTED.
PR_CORE_TARGET_SCHEMA_VERSION bumped 3 -> 4.

Piece 2 — Drug node enrichment + stable @id = {permalink}#drug (ratified contract).
Reads _pr_* schema-input meta. molecularWeight in g/mol. Empty-prop guard throughout.

Piece 3 — Yoast-integrated emission via wpseo_schema_graph_pieces (priority 11),
wpseo_schema_webpage_type (MedicalWebPage retype), wpseo_schema_graph (enrichment).
Standalone @graph fallback retained. No duplicate WebPage/BreadcrumbList.
FAQPage emitted only when _pr_faq_items populated.

Supporting: PR_Core_Schema_Sanitizers, PR_Core_Pubchem_Client, CONTEXT.md,
ARCHITECTURE.md, CONVENTIONS.md, CHANGELOG.md, uninstall.php purge.
Tests: test-migration-0004.php (20 assertions), test-jsonld.php (29 assertions).

Agent-Session: peptide-schema-backfill v0.6.0
2026-06-13 05:01:59 +00:00
peptiderepo
c52cf9b3d6 feat: verification scanner + admin UI (PR Core v0.4.0)
Implements recurring verification scanner, dashboard widget, per-post sidebar meta box, reader-facing last-verified display, and unified settings panel. Bumps to v0.4.0.

Co-authored-by: peptiderepo <peptiderepo@users.noreply.github.com>
2026-04-27 12:24:57 +07:00
peptiderepo
3050292fcf fix(cpt): remove rest_namespace so Gutenberg block editor can load peptide posts (v0.3.2)
Removes rest_namespace => pr-core/v1 from CPT registration. Gutenberg fetches wp/v2 hardcoded — custom namespace caused 404 and editor crash on all 89 peptide entries. WordPress defaults to wp/v2.

QA: PASS (2026-04-25-9d4ce64c.md)
CI: green
PR: #5
2026-04-25 01:57:30 +07:00
peptiderepo
f086b89e2d feat(cpt): consolidate peptide CPT with PSA; drop pr_peptide (v0.2.0) (#1)
Consolidates the `peptide` CPT under PR Core ownership, dropping the `pr_peptide` slug-collision that was 404ing all 89 peptide detail pages.

- POST_TYPE: pr_peptide -> peptide
- TAX_CATEGORY: pr_peptide_category -> peptide_category
- TAX_FAMILY + pr_peptide_family taxonomy removed
- Defensive post_type_exists/taxonomy_exists guards on both registrations
- Args harmonized as superset of PSA + prior PR Core (adds thumbnail support)
- Activation hook + init:999 version-change flush handler
- Uninstall scoped to _pr_core_authored flag (PSA-authored posts survive)
- Plugin version 0.1.1 -> 0.2.0, CHANGELOG in same commit
- ARCHITECTURE.md + CONVENTIONS.md updated with CPT ownership rule

QA gate verdict: PASS (qa-reviews/peptide-repo-core/2026-04-22-874f93b.md)
Sibling release: peptiderepo/peptide-search-ai#15 (PSA v4.5.0)

Known follow-up: manage_peptide_content capability is not granted to any role as of v0.2.0. No current UI/theme reads or writes PR Core-defined meta keys, so no regression. Follow-up thread to decide role assignment.
2026-04-22 16:44:04 +07:00