From 83bb404a94d05775fa0716b0fb03f8f79ff9e2d2 Mon Sep 17 00:00:00 2001 From: eddiesoehnel Date: Sun, 11 Oct 2026 16:58:11 -0600 Subject: [PATCH] added --- CHANGELOG.md | 12 ++ CITATION.cff | 4 +- README.md | 8 ++ VERSION | 2 +- docs/README.md | 1 + docs/poppy.md | 69 +++++++++++ repository.json | 26 ++-- skills-scripts/build_discovery_files.py | 47 +++++++- .../discovery-files-materialization-skill.md | 12 +- skills-scripts/publish_hugo_output.py | 6 +- .../skill-convert-builder-for-new-website.md | 3 + skills.md | 2 +- tests/README.md | 4 +- tests/test_poppy_discovery.py | 114 ++++++++++++++++++ 14 files changed, 292 insertions(+), 18 deletions(-) create mode 100644 docs/poppy.md create mode 100644 tests/test_poppy_discovery.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 5274259..157c366 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,18 @@ This repo uses SemVer-style releases: ## [Unreleased] +## [0.3.0] - 2026-10-10 + +### Added + +- Added deterministic Poppy draft 0.1 ordinary-web manifest generation, validation, and discovery links. +- Protected the generated manifest from stale Hugo output during copying. +- Added adaptation guidance and temporary-output tests; no session, API, agent, or transaction runtime is advertised. + +### Fixed + +- Generate root helper files before final sitemap collection so a fresh discovery build passes validation. + ## [0.2.0] - 2026-07-25 ### Added diff --git a/CITATION.cff b/CITATION.cff index dfd9ea0..1aa9611 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -2,8 +2,8 @@ cff-version: 1.2.0 message: "If you use this website builder, please cite it using this metadata." title: "Structured Website Builder" type: software -version: 0.2.0 -date-released: 2026-07-25 +version: 0.3.0 +date-released: 2026-10-10 authors: - family-names: "Soehnel" given-names: "Eddie" diff --git a/README.md b/README.md index 8be9b1f..dc058a3 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,10 @@ This process builds a website that is highly structured for SEO and GEO for the If you have existing big, complex websites in platforms like wordpress, shopify, magento, etc., keep them as your human layer, and use the process in this builder to create corresponding content for AI. I suggest you begin first in this document (https://projects.eddiesoehnel.com/adminprojects/seo-geo) to get your bearings on SEO, GEO and findability in the AI era, and how and why this builder fits. +## Personal Agent Protocol (Poppy) + +The final discovery stage now generates `public/.well-known/poppy.json` for Personal Agent Protocol draft 0.1. The supported profile declares ordinary website access only. See [Poppy integration](docs/poppy.md) for adaptation, validation, deployment checks, and future runtime requirements. + # AI-native The idea is to build this front website in git and publish it using apps, skills and scripts. Codex or any AI can access it to complete tasks. Over time we can automate all this via a harness so that AI will do more and more of maintaining and publishing new content. We create a harness so that AI can proactively update content (like a Wiki if one is built) as other elements of the business change. We automate through AI the maintenance of all the content ontology (relationships, edges and nodes). If we add ecommerce carts (human or AI - like x402), AI manages all of that. @@ -193,6 +197,7 @@ When output passes human testing, run this scrtipt to copy the Hugo output to th agents.md skills.md ai-index.json + .well-known/poppy.json (protected against stale Hugo output) Run it with @@ -251,6 +256,8 @@ See contact-form-deployment.md for the infrastracture. - .well-known/ai-catalog.json - uses skill ai-catalog-materialization-skill.md through build_discovery_files.py. It advertises actual public agent-usable resources and stays separate from the content-focused ai-index.json. +- .well-known/poppy.json - generated by build_discovery_files.py from SITE_URL and SITE_TITLE; ordinary website access only, without sessions or API claims. + - robots.txt - sitemap.xml @@ -369,6 +376,7 @@ As pages are added, amended, or deleted, keep this listing current. The current /.well-known/ ai-catalog.json agent-card.json + poppy.json security.txt /assets/ diff --git a/VERSION b/VERSION index 0ea3a94..0d91a54 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2.0 +0.3.0 diff --git a/docs/README.md b/docs/README.md index 22e9399..5b17d70 100644 --- a/docs/README.md +++ b/docs/README.md @@ -10,6 +10,7 @@ | [`../CONTRIBUTING.md`](../CONTRIBUTING.md) | Contribution and validation expectations | | [`../content-index.json`](../content-index.json) | Repository-level discovery index for source documents | | [`../repository.json`](../repository.json) | Machine-readable repository manifest | +| [`poppy.md`](poppy.md) | Poppy draft 0.1 website discovery, adaptation, and verification | The root `content-index.json` catalogs authoritative source documents under `content/`. It does not replace the generated public `ai-index.json`, semantic diff --git a/docs/poppy.md b/docs/poppy.md new file mode 100644 index 0000000..7865c77 --- /dev/null +++ b/docs/poppy.md @@ -0,0 +1,69 @@ +# Poppy discovery in this builder + +This builder implements the ordinary-website discovery profile of +[Personal Agent Protocol draft 0.1](https://personalagentprotocol.org/docs/spec), +updated 2026-10-09 and checked 2026-10-10. Review the current draft before a +release. The generated declaration is intentionally limited to current static +website access; session and transaction features require additional runtime work. + +## Generate and adapt + +Set `SITE_URL` and `SITE_TITLE` in `skills-scripts/build_discovery_files.py` +when adapting this template. Use an HTTPS domain root without credentials, +port, query, fragment, or subdirectory. The organization name is the site's +display name; its domain is derived from that URL, not the repository host. +Keep the Hugo base URL and other build scripts aligned with the same website. + +Follow README steps 1–5: reviewed content, semantic chunks and QA, source/Hugo +sync, Hugo render and semantic checks, copy HTML, build the AI index, then: + +```text +python skills-scripts/build_discovery_files.py +``` + +This writes `public/.well-known/poppy.json`: + +```json +{ + "protocol_version": "0.1", + "organization": {"name": "iNDX Earth", "domain": "indx.earth"}, + "web": {} +} +``` + +The generator validates the configured identity and supported profile. The +publication copy script preserves this path against stale Hugo static files. +Regenerate discovery after the HTML copy as the normal final step. Commit source +changes; generated `public/` output remains excluded from source control. + +`llms.txt`, `agents.md`, and the local `agent-card.json` discovery map link to +the manifest. Keep `ai-index.json` and the resource catalog for content retrieval. +The local agent card and catalog are separate contracts from Poppy. + +## Verify publication + +Run the repository tests, review generated output, then obtain deployment +approval under `AGENTS.md` and follow `PUBLICATION_WORKFLOW.md`. On the deployed +domain, fetch `https://{domain}/.well-known/poppy.json` and verify a successful +JSON response, HTTPS through any redirect, expected organization identity, and +the absence of an HTML fallback, access challenge, or stale cached manifest. +Ensure the host serves dot directories and uses an appropriate JSON content +type and caching policy. Confirm normal visitor access and the intended crawler +and edge policies. Local tests cannot prove the deployed response. + +## Extending beyond website discovery + +Do not hand-edit generated output to add future capabilities. Implement them +in the runtime first, then extend the generator and tests in a reviewed change. +The existing contact API is not advertised as a Poppy API: CAPTCHA, SMTP, and +an HTTP endpoint alone do not implement protocol sessions or authorization. + +For future work, use a separate staging plan tied to a specific business need. +Verify OAuth issuer/domain binding, client identity, session isolation, scopes, +consent, revocation, DPoP and replay protection; apply the MCP token rules when +relevant. Publish OpenAPI/MCP or company-agent URLs only after their integration +works. If using the optional operations extension, test exact-term approval and +safe retries. Keep credentials and user records outside this public template. + +The current tests enforce only this builder's supported ordinary-web profile. +They do not certify a full Poppy implementation or predict AI search rankings. diff --git a/repository.json b/repository.json index 409a593..62ee6bf 100644 --- a/repository.json +++ b/repository.json @@ -17,9 +17,9 @@ "repository_status": "active", "visibility": "public", "maturity": "experimental", - "version": "0.2.0", + "version": "0.3.0", "created_at": "2026-06-06", - "updated_at": "2026-07-25", + "updated_at": "2026-10-10", "resource_types": [ "application", "documentation", @@ -53,7 +53,8 @@ "ai-discovery", "generative-engine-optimization", "semantic-content", - "structured-data" + "structured-data", + "personal-agent-protocol" ] }, "audiences": [ @@ -73,7 +74,8 @@ "Render and publish a static website with semantic discovery metadata.", "Generate AI indexes, discovery files, chunk data, and QA artifacts.", "Adapt the builder for a new brand, domain, content set, and deployment target.", - "Provide an optional FastAPI contact form backed by environment-managed credentials." + "Provide an optional FastAPI contact form backed by environment-managed credentials.", + "Generate Poppy draft 0.1 discovery for ordinary website access only." ], "use_cases": [ "Create an AI-readable companion site for an existing platform website.", @@ -181,6 +183,13 @@ "title": "Agent Instructions", "description": "Repository-scoped operating, preservation, and validation rules.", "required_for_use": true + }, + { + "path": "docs/poppy.md", + "type": "documentation", + "title": "Poppy Discovery Integration", + "description": "Supported ordinary-web discovery profile, generation, adaptation, validation, and publication checks.", + "required_for_use": false } ], "relationships": { @@ -189,7 +198,8 @@ "depends_on": [], "related_resources": [ "https://forge.paddlenet.earth/industrySIG/structured-website-builder-OPEN", - "https://projects.eddiesoehnel.com/adminprojects/master-findability-framework-OPEN" + "https://projects.eddiesoehnel.com/adminprojects/master-findability-framework-OPEN", + "https://projects.eddiesoehnel.com/adminprojects/ai-knowledge-structure-OPEN" ], "supersedes": [], "superseded_by": [] @@ -214,7 +224,8 @@ "source_references": [ "README.md", "PUBLICATION_WORKFLOW.md", - "sanitization-map.md" + "sanitization-map.md", + "https://personalagentprotocol.org/docs/spec" ] }, "maintenance": { @@ -240,7 +251,8 @@ "skills-scripts/", "hugo-html-builder/", "api/", - "docs/" + "docs/", + "docs/poppy.md" ], "exclude_by_default": [ "_original/", diff --git a/skills-scripts/build_discovery_files.py b/skills-scripts/build_discovery_files.py index aee88ea..e68092d 100644 --- a/skills-scripts/build_discovery_files.py +++ b/skills-scripts/build_discovery_files.py @@ -9,6 +9,7 @@ Outputs: - public/.well-known/ai-catalog.json - public/.well-known/security.txt - public/.well-known/agent-card.json + - public/.well-known/poppy.json (draft 0.1, ordinary website access only) """ from __future__ import annotations @@ -302,6 +303,7 @@ def build_llms_txt(entries: list[SitemapEntry]) -> str: "## Machine-Readable URLs", f"- {SITE_URL}/ai-index.json", f"- {SITE_URL}/.well-known/ai-catalog.json", + f"- {SITE_URL}/.well-known/poppy.json (Personal Agent Protocol draft 0.1; ordinary website access)", f"- {SITE_URL}/sitemap.xml", "- /data/open/pages/**/chunks.json", "- /data/open/pages/**/qa.json", @@ -332,6 +334,7 @@ Canonical site: {SITE_URL}/ ## Retrieval Policy - Use `{SITE_URL}/.well-known/ai-catalog.json` to discover public agent-usable resources. +- `{SITE_URL}/.well-known/poppy.json` declares ordinary website access only (Personal Agent Protocol draft 0.1); it grants no session, account, API, or transaction access. - Start with `{SITE_URL}/ai-index.json` to understand resources, artifacts, access type, and retrieval priority. - Use `{SITE_URL}/sitemap.xml` for canonical human-facing URLs. - Use `/data/open/pages/**/chunks.json` for semantic retrieval and `/data/open/pages/**/qa.json` for question-answer and workflow hints. @@ -382,6 +385,7 @@ def build_agent_card_json() -> str: "license": f"{SITE_URL}/wiki/license/", "discovery": { "ai_catalog": f"{SITE_URL}/.well-known/ai-catalog.json", + "poppy": f"{SITE_URL}/.well-known/poppy.json", "ai_index": f"{SITE_URL}/ai-index.json", "sitemap": f"{SITE_URL}/sitemap.xml", "llms": f"{SITE_URL}/llms.txt", @@ -401,6 +405,40 @@ def build_agent_card_json() -> str: return json.dumps(payload, indent=2, ensure_ascii=False) + "\n" +def build_poppy_json() -> str: + """Generate only the ordinary-web profile from Poppy draft 0.1 sections 3/5. + + Do not advertise auth, APIs, agents, browser sessions, or extensions here. + They require a separately implemented and verified protocol runtime. + """ + site = urlparse(SITE_URL) + if ( + site.scheme != "https" + or not site.hostname + or site.username is not None + or site.password is not None + or site.netloc != site.hostname + or site.path not in {"", "/"} + or site.query + or site.fragment + ): + raise ValueError("Poppy discovery requires SITE_URL to be an HTTPS domain root") + if not SITE_TITLE.strip(): + raise ValueError("Poppy discovery requires a non-empty SITE_TITLE") + payload = { + "protocol_version": "0.1", + "organization": {"name": SITE_TITLE, "domain": site.hostname}, + "web": {}, + } + return json.dumps(payload, indent=2, ensure_ascii=False) + "\n" + + +def validate_poppy_json(payload: object) -> None: + """Local supported-profile check, not an official full-protocol validator.""" + if payload != json.loads(build_poppy_json()): + raise RuntimeError("poppy.json must match the configured draft 0.1 ordinary-web profile") + + def build_ai_catalog_json() -> str: payload = { "specVersion": "1.0", @@ -526,11 +564,13 @@ def validate_outputs() -> None: ".well-known/ai-catalog.json", ".well-known/security.txt", ".well-known/agent-card.json", + ".well-known/poppy.json", ): path = PUBLIC_ROOT / filename if not path.exists() or path.stat().st_size == 0: raise RuntimeError(f"{filename} was not created") ai_catalog = json.loads(read_text(PUBLIC_ROOT / ".well-known" / "ai-catalog.json")) + validate_poppy_json(json.loads(read_text(PUBLIC_ROOT / ".well-known" / "poppy.json"))) if ai_catalog.get("specVersion") != "1.0" or not ai_catalog.get("entries"): raise RuntimeError("ai-catalog.json is missing its supported specVersion or entries") for entry in ai_catalog["entries"]: @@ -551,15 +591,20 @@ def validate_outputs() -> None: def main() -> None: + poppy = build_poppy_json() # Validate configuration before writing any output. + entries = collect_sitemap_entries() + # Materialize helpers before collecting the final sitemap on a fresh build. + write_text(PUBLIC_ROOT / "llms.txt", build_llms_txt(entries)) + write_text(PUBLIC_ROOT / "skills.md", build_skills_md()) entries = collect_sitemap_entries() write_text(PUBLIC_ROOT / "robots.txt", build_robots()) write_text(PUBLIC_ROOT / "sitemap.xml", build_sitemap(entries)) write_text(PUBLIC_ROOT / "llms.txt", build_llms_txt(entries)) write_text(PUBLIC_ROOT / "agents.md", build_agents_md(entries)) - write_text(PUBLIC_ROOT / "skills.md", build_skills_md()) write_text(PUBLIC_ROOT / ".well-known" / "ai-catalog.json", build_ai_catalog_json()) write_text(PUBLIC_ROOT / ".well-known" / "security.txt", build_security_txt()) write_text(PUBLIC_ROOT / ".well-known" / "agent-card.json", build_agent_card_json()) + write_text(PUBLIC_ROOT / ".well-known" / "poppy.json", poppy) validate_outputs() print(f"Wrote discovery files in {PUBLIC_ROOT} for {len(entries)} sitemap URLs.") diff --git a/skills-scripts/discovery-files-materialization-skill.md b/skills-scripts/discovery-files-materialization-skill.md index 1cb884a..11d9184 100644 --- a/skills-scripts/discovery-files-materialization-skill.md +++ b/skills-scripts/discovery-files-materialization-skill.md @@ -10,6 +10,7 @@ Using this skill, reference the current README.md process document, existing pub - `public/agents.md` - `public/skills.md` - `public/.well-known/ai-catalog.json` +- `public/.well-known/poppy.json` (draft 0.1 ordinary-web profile) --- @@ -48,7 +49,7 @@ Use: python skills-scripts/build_discovery_files.py ``` -The script materializes all five files deterministically. Patch the script when the policy or output shape changes; do not repeatedly hand-author these files. +The script materializes the root and well-known discovery files deterministically. Read `docs/poppy.md` for the Poppy contract; this builder supports ordinary website access only. Patch the script when the policy or output shape changes; do not repeatedly hand-author these files. ## Phases @@ -128,7 +129,11 @@ This is a public inventory, not internal secrets or implementation logs. Apply `ai-catalog-materialization-skill.md` to create `public/.well-known/ai-catalog.json`. -### Phase 8: Validation +### Phase 8: Poppy Discovery + +Generate `.well-known/poppy.json` through the same script. Use `SITE_TITLE` for the organization display name and derive its domain from `SITE_URL`. Keep `protocol_version` at `0.1` and `web` empty for ordinary browsing. Do not add auth, APIs, company agents, browser sessions, or extensions without a tested runtime and an updated generator contract. Link the manifest from generated agent guidance and discovery metadata. + +### Phase 9: Validation Validate: @@ -139,6 +144,9 @@ Validate: - `robots.txt` references the sitemap - `llms.txt`, `agents.md`, and `skills.md` exist and are non-empty - `.well-known/ai-catalog.json` parses and advertises only real public resources +- `.well-known/poppy.json` parses and matches the configured ordinary-web profile +- copy/publish preserves the generated Poppy manifest against stale Hugo output +- after authorized deployment, the well-known HTTPS URL returns the expected JSON and identity - no credentials or private paths are present ## Anti-Patterns diff --git a/skills-scripts/publish_hugo_output.py b/skills-scripts/publish_hugo_output.py index 2c84be6..7515fb9 100644 --- a/skills-scripts/publish_hugo_output.py +++ b/skills-scripts/publish_hugo_output.py @@ -7,7 +7,7 @@ Run after: 4. python skills-scripts/build_discovery_files.py This script copies files from hugo-html-builder/public into public while -preserving repo-level discovery files generated outside Hugo. +preserving repo-level discovery files and the Poppy manifest generated outside Hugo. """ from __future__ import annotations @@ -31,6 +31,8 @@ PRESERVE_AT_PUBLIC_ROOT = { def should_preserve(relative_path: Path) -> bool: + if relative_path.as_posix() == ".well-known/poppy.json": + return True return len(relative_path.parts) == 1 and relative_path.name in PRESERVE_AT_PUBLIC_ROOT @@ -61,7 +63,7 @@ def main() -> None: copied, skipped = copy_hugo_output() print(f"Copied {copied} Hugo output files into {PUBLIC_ROOT}") if skipped: - print("Preserved root discovery files:") + print("Preserved discovery files:") for path in skipped: print(f"- {path}") diff --git a/skills-scripts/skill-convert-builder-for-new-website.md b/skills-scripts/skill-convert-builder-for-new-website.md index 847ce7d..8d7f48b 100644 --- a/skills-scripts/skill-convert-builder-for-new-website.md +++ b/skills-scripts/skill-convert-builder-for-new-website.md @@ -64,6 +64,7 @@ Remove old generated and copied-site artifacts, after confirming paths resolve i - `/public/agents.md`; - `/public/skills.md`; - `/public/ai-index.json`; +- stale `/public/.well-known/poppy.json`; regenerate it for the new domain; - `/public/data/`; - old public section directories from the copied site; - `/public/healthz/`; @@ -199,6 +200,7 @@ Recommended `.well-known` files: - `/public/.well-known/security.txt`; - `/public/.well-known/agent-card.json`; +- `/public/.well-known/poppy.json` (draft 0.1 ordinary-web discovery; see `docs/poppy.md`); - optionally `/public/.well-known/agent-skills.json`. Update `skills-scripts/sync_content_to_hugo.py`: @@ -329,6 +331,7 @@ rg -n "old-domain|old-brand|old-logo|old analytics ID|mojibake-patterns" . Check: +- Poppy organization name/domain match the new SITE_TITLE/SITE_URL and advertise only ordinary website access; - no old domain in generated HTML/JSON/discovery files; - no old logo references; - no old analytics ID; diff --git a/skills.md b/skills.md index cdc2615..de59a31 100644 --- a/skills.md +++ b/skills.md @@ -13,7 +13,7 @@ deterministic helper scripts. | `semantic-qa-materialization-skill.md` | Generate QA artifacts aligned with semantic chunks | | `html-semantic-artifacts-checker-skill.md` | Validate rendered semantic links and JSON-LD | | `ai-index-discovery-materialization-skill.md` | Build the public content-oriented AI index | -| `discovery-files-materialization-skill.md` | Build sitemap, robots, llms, agents, skills, and well-known discovery files | +| `discovery-files-materialization-skill.md` | Build sitemap, robots, llms, agents, skills, and well-known discovery files including Poppy ordinary-web discovery | | `ai-catalog-materialization-skill.md` | Materialize the public agent-usable resource catalog | Supporting operational documents include `contact-form-deployment.md`, diff --git a/tests/README.md b/tests/README.md index c34f1b3..4717697 100644 --- a/tests/README.md +++ b/tests/README.md @@ -6,6 +6,6 @@ Run the repository metadata and structural tests from the repository root: python -m unittest discover -s tests -p "test_*.py" ``` -These tests are read-only. They validate repository metadata, versions, +These tests preserve authored content and publication output. They validate repository metadata, versions, declared paths, content-index integrity, source documents, and Python syntax. -They do not run the mutating Hugo publication pipeline. +The Poppy tests also generate discovery files in a temporary directory and verify rebranding, unsupported-capability rejection, and preservation during HTML copying. They do not run the Hugo rendering or deployment pipeline. diff --git a/tests/test_poppy_discovery.py b/tests/test_poppy_discovery.py new file mode 100644 index 0000000..05ebf1e --- /dev/null +++ b/tests/test_poppy_discovery.py @@ -0,0 +1,114 @@ +from __future__ import annotations + +import importlib.util +import json +import sys +import tempfile +import unittest +from pathlib import Path +from unittest.mock import patch + + +ROOT = Path(__file__).resolve().parents[1] + + +def load_script(name: str): + spec = importlib.util.spec_from_file_location(name, ROOT / "skills-scripts" / f"{name}.py") + module = importlib.util.module_from_spec(spec) + sys.modules[name] = module + spec.loader.exec_module(module) + return module + + +discovery = load_script("build_discovery_files") +publisher = load_script("publish_hugo_output") + + +class PoppyDiscoveryTests(unittest.TestCase): + def test_ordinary_web_manifest(self): + manifest = json.loads(discovery.build_poppy_json()) + self.assertEqual(manifest, { + "protocol_version": "0.1", + "organization": {"name": "iNDX Earth", "domain": "indx.earth"}, + "web": {}, + }) + + def test_rebranding_uses_website_identity(self): + with patch.object(discovery, "SITE_URL", "https://www.example.com/"), patch.object( + discovery, "SITE_TITLE", "Example Company" + ): + manifest = json.loads(discovery.build_poppy_json()) + self.assertEqual(manifest["organization"], { + "name": "Example Company", "domain": "www.example.com" + }) + + def test_invalid_site_configuration_fails_before_writes(self): + invalid_urls = [ + "http://example.com", "https:///", "https://user:pass@example.com", + "https://example.com:8443", "https://example.com/site/", + "https://example.com?token=placeholder", "https://example.com#home", + ] + for url in invalid_urls: + with self.subTest(url=url), patch.object(discovery, "SITE_URL", url), patch.object( + discovery, "write_text" + ) as write: + with self.assertRaises(ValueError): + discovery.main() + write.assert_not_called() + with patch.object(discovery, "SITE_TITLE", " "): + with self.assertRaises(ValueError): + discovery.build_poppy_json() + + def test_validation_rejects_stale_or_unimplemented_claims(self): + mutations = [ + {"protocol_version": "1.0"}, + {"organization": {"name": "Old Brand", "domain": "old.example"}}, + {"web": {"browser_session_endpoint": "https://indx.earth/session"}}, + {"auth": {"issuer": "https://auth.example.com"}}, + {"apis": [{"type": "mcp", "url": "https://example.com/mcp"}]}, + {"agent": {"protocols": []}}, + {"extensions": {"operations": {"version": "1"}}}, + ] + for mutation in mutations: + with self.subTest(mutation=mutation): + manifest = json.loads(discovery.build_poppy_json()) + manifest.update(mutation) + with self.assertRaises(RuntimeError): + discovery.validate_poppy_json(manifest) + + def test_discovery_generation_validation_and_copy(self): + with tempfile.TemporaryDirectory(prefix="poppy-test-", dir=ROOT) as directory: + root = Path(directory) + public = root / "public" + hugo = root / "hugo" + hugo.mkdir() + with patch.object(discovery, "PUBLIC_ROOT", public), patch.object( + discovery, "HUGO_PUBLIC", hugo + ), patch.object(publisher, "PUBLIC_ROOT", public), patch.object( + publisher, "HUGO_PUBLIC", hugo + ): + discovery.main() + target = public / ".well-known/poppy.json" + expected = target.read_bytes() + for name in ("llms.txt", "agents.md", ".well-known/agent-card.json"): + self.assertIn("/.well-known/poppy.json", (public / name).read_text()) + stale = hugo / ".well-known/poppy.json" + stale.parent.mkdir() + stale.write_text('{"stale": true}') + (hugo / "index.html").write_text("Example") + copied, skipped = publisher.copy_hugo_output() + self.assertEqual(1, copied) + self.assertIn(".well-known/poppy.json", skipped) + self.assertEqual(expected, target.read_bytes()) + discovery.main() + self.assertEqual(expected, target.read_bytes()) + target.write_text('{"protocol_version": "9.0"}') + with self.assertRaises(RuntimeError): + discovery.validate_outputs() + target.unlink() + with self.assertRaises(RuntimeError): + discovery.validate_outputs() + + +if __name__ == "__main__": + unittest.main()