diff --git a/SECURITY.md b/SECURITY.md index 66f84e2..0a781fb 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -19,8 +19,8 @@ needed to reproduce. A report about a documentation repository or a shared workflow is in scope when it would let someone change what a build or a published document says. A report about a live deployment belongs with the repository that owns the deployment; -that repository's own policy names where its credentials live and how they are -rotated. +credential storage and rotation procedures live in the private operations +repository, not in public security policies. ## What happens next diff --git a/docs/STYLE_GUIDE.md b/docs/STYLE_GUIDE.md index 0a77fef..61f674f 100644 --- a/docs/STYLE_GUIDE.md +++ b/docs/STYLE_GUIDE.md @@ -252,30 +252,26 @@ When a repository keeps a changelog, follow Keep a Changelog. The file is `CHANG Write PR descriptions in English. Use the repository's template and keep the sections that apply; write "none" where a section of the template does not apply. ```markdown -## Summary +## AI assistance - + -## Why - - - -## Changes +## What changed - - -## Testing +## How verified - + -## Risk and rollback +## Why - + -## Breaking changes +## Risk - + ``` Do not paste internal job logs, agent transcripts, evidence tables, or approval notes into a PR description. A documentation-only PR should say so in the Summary. diff --git a/docs/architecture.md b/docs/architecture.md index 4762929..e5d0871 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -13,7 +13,7 @@ interfaces and data formats. ## Repository responsibilities -The following map covers 26 repositories. Groups describe responsibility, not a +The following map covers 29 repositories. Groups describe responsibility, not a requirement to combine repositories or release them together. | Responsibility | Repositories | Owned behavior | @@ -27,7 +27,8 @@ requirement to combine repositories or release them together. | AI task service | `QuantAIService` | Task and advisory result contracts, model-service integration and related clients. | | Connection operations | `IBKRGatewayManager`, `SchwabTokenAutoRefresher` | Gateway lifecycle and credential-renewal operations. | | Advisory research | `QuantAdvisorResearch`, `PoliticalEventTrackingResearch` | Research reports and event context under the advisory boundary. | -| Organization conventions | `.github` | Shared documentation, contribution templates, opt-in secret scans and organization metadata. | +| Internal operations (private) | `QuantInternalOps` | Private deployment wrappers, GCP free-tier guards, operational runbooks and internal progress tracking. | +| Organization conventions and site | `.github`, `quantstrategylab.github.io`, `MonitorDeployPilot` | Shared documentation, contribution templates, secret scans, organization landing site and isolated deployment workflow pilot. | Supported modes and broker capabilities belong to the relevant platform repository. A shadow implementation or an offline adapter does not establish diff --git a/scripts/check_cross_repo_links.py b/scripts/check_cross_repo_links.py index 5ea6d16..861411d 100644 --- a/scripts/check_cross_repo_links.py +++ b/scripts/check_cross_repo_links.py @@ -56,7 +56,7 @@ LINK = re.compile(r"\[[^\]]*\]\(([^)\s]+)\)") # https://github.com///(blob|tree)// GH_REF = re.compile( - r"https?://github\.com/([^/]+)/([^/]+)/(?:blob|tree)/([^/]+)/(.+?)(?:#.*)?$" + r"https?://github\.com/([^/]+)/([^/]+)/(blob|tree)/([^/]+)/(.+?)(?:#.*)?$" ) SHA = re.compile(r"[0-9a-f]{7,40}") @@ -182,6 +182,12 @@ def scan(repos: dict[str, Path]) -> tuple[list[dict], list[dict], int]: } if note: unverifiable.append({**record, "reason": note}) + elif kind == "github-tree": + prefix = target_path.rstrip("/") + "/" + if target_path not in files[target_repo] and not any( + p.startswith(prefix) for p in files[target_repo] + ): + broken.append(record) elif target_path not in files[target_repo]: broken.append(record) return broken, unverifiable, pinned @@ -193,13 +199,14 @@ def classify( """Return (target_repo, target_path, kind, unverifiable_reason).""" m = GH_REF.match(url) if m: - _, target_repo, ref, path = m.groups() + _, target_repo, ref_kind, ref, path = m.groups() if SHA.fullmatch(ref): return target_repo, path, "pinned", "commit sha" + kind = f"github-{ref_kind}" branch = branches.get(target_repo) if branch is not None and ref != branch: - return target_repo, path, "github-blob", f"ref {ref} is not the default branch" - return target_repo, path, "github-blob", "" + return target_repo, path, kind, f"ref {ref} is not the default branch" + return target_repo, path, kind, "" if url.startswith(("http", "#", "mailto")): return None diff --git a/scripts/check_style.py b/scripts/check_style.py index 50e1dd0..eb4302e 100755 --- a/scripts/check_style.py +++ b/scripts/check_style.py @@ -556,18 +556,15 @@ def check_agent_files(root: Path, report: Report) -> None: ) -def check_docs_baseline(root: Path, report: Report) -> None: - """The file set a reader expects, split by what the repository is. - - A LICENSE is the signal: a repository that grants rights to outside readers - owes them a contribution path, a way to report a vulnerability, and a - conduct policy. A repository that does not grant them is internal, and an - internal repository needs one thing from this list — where credentials live - and what to do when one leaks — not a public disclosure process it will - never run. +def check_docs_baseline(root: Path, report: Report, visibility: str = "public") -> None: + """The file set a reader expects, split by repository visibility. + + Public repositories owe outside readers a license, contribution path, + vulnerability disclosure policy, and code of conduct. Private repositories + only require SECURITY.md for credential handling and rotation. """ - if (root / "LICENSE").exists(): - required = ["CONTRIBUTING.md", "SECURITY.md", "CODE_OF_CONDUCT.md"] + if visibility == "public" or (root / "LICENSE").exists(): + required = ["LICENSE", "CONTRIBUTING.md", "SECURITY.md", "CODE_OF_CONDUCT.md"] kind = "public" else: required = ["SECURITY.md"] @@ -580,6 +577,29 @@ def check_docs_baseline(root: Path, report: Report) -> None: ) +def check_doc_hygiene_advisory(root: Path, report: Report) -> None: + """Report non-blocking semantic hygiene cues (orphan docs, zh-CN-only files).""" + docs_dir = root / "docs" + if docs_dir.is_dir(): + doc_mds = [p for p in docs_dir.rglob("*.md") if p.name != "README.md"] + if len(doc_mds) > 5 and not (docs_dir / "README.md").exists(): + report.add( + "docs_advisory", + f"docs/ has {len(doc_mds)} documents but no docs/README.md index", + ) + for path in iter_files(root): + if not is_markdown(path): + continue + if path.name.endswith(".zh-CN.md"): + en_sibling = path.with_name(path.name[:-len(".zh-CN.md")] + ".md") + if not en_sibling.exists(): + rel = path.relative_to(root).as_posix() + report.add( + "docs_advisory", + f"{rel}: Chinese sibling has no English source file (section 4)", + ) + + QUOTE_MARKS = "\"'\u201c\u201d\u2018\u2019" QUOTED_TERM = re.compile(r"[\"\'\u201c\u2018][^\"\'\u201c\u201d\u2018\u2019]{1,40}[\"\'\u201d\u2019]") @@ -753,7 +773,8 @@ def main(argv: list[str] | None = None) -> int: check_links(root, report) check_agent_files(root, report) check_language(root, report) - check_docs_baseline(root, report) + check_docs_baseline(root, report, visibility=args.visibility) + check_doc_hygiene_advisory(root, report) check_leaks(root, report) check_internal_paths(root, report) diff --git a/scripts/test_style.py b/scripts/test_style.py index a1afba1..4ac8572 100644 --- a/scripts/test_style.py +++ b/scripts/test_style.py @@ -375,30 +375,34 @@ class DocsBaselineTest(CheckerTestCase): def test_public_repository_needs_the_reader_file_set(self): self.write("LICENSE", "MIT\n") report = self.report() - check_style.check_docs_baseline(self.root, report) + check_style.check_docs_baseline(self.root, report, visibility="public") found = self.messages(report, "docs") self.assertTrue(any("CONTRIBUTING.md" in m for m in found)) self.assertTrue(any("CODE_OF_CONDUCT.md" in m for m in found)) + def test_public_repository_without_license_is_reported(self): + report = self.report() + check_style.check_docs_baseline(self.root, report, visibility="public") + found = self.messages(report, "docs") + self.assertTrue(any("LICENSE" in m for m in found)) + def test_public_repository_with_the_file_set_passes(self): self.write("LICENSE", "MIT\n") for name in ("CONTRIBUTING.md", "SECURITY.md", "CODE_OF_CONDUCT.md"): self.write(name, "# " + name + "\n") report = self.report() - check_style.check_docs_baseline(self.root, report) + check_style.check_docs_baseline(self.root, report, visibility="public") self.assertEqual(self.messages(report, "docs"), []) def test_private_repository_needs_only_the_credential_doc(self): - # No LICENSE means the repository grants nothing to outside readers, so - # a public disclosure process would be a document nobody runs. self.write("SECURITY.md", "# Credentials\n") report = self.report() - check_style.check_docs_baseline(self.root, report) + check_style.check_docs_baseline(self.root, report, visibility="private") self.assertEqual(self.messages(report, "docs"), []) def test_private_repository_without_the_credential_doc_is_reported(self): report = self.report() - check_style.check_docs_baseline(self.root, report) + check_style.check_docs_baseline(self.root, report, visibility="private") self.assertTrue(any("SECURITY.md" in m for m in self.messages(report, "docs"))) @@ -573,11 +577,18 @@ def test_gitignored_notes_do_not_block_while_staged_notes_do(self): self.write(".gitignore", GITIGNORE_BLOCK) self.write("AGENTS.md", "# rules\n\n" + check_style.CONTENT_BOUNDARY + "\n") self.write("CLAUDE.md", "@AGENTS.md\n") + self.write("LICENSE", "MIT\n") + self.write("CONTRIBUTING.md", "# Contributing\n") + self.write("CODE_OF_CONDUCT.md", "# Code of Conduct\n") self.write("SECURITY.md", "# Security\n") self.git("init", "--quiet") self.git("config", "user.name", "Test User") self.git("config", "user.email", "test@example.com") - self.git("add", ".gitignore", "AGENTS.md", "CLAUDE.md", "SECURITY.md", "README.md") + self.git( + "add", + ".gitignore", "AGENTS.md", "CLAUDE.md", + "LICENSE", "CONTRIBUTING.md", "CODE_OF_CONDUCT.md", "SECURITY.md", "README.md", + ) self.write("docs/changes/task/change-card.md", "# Card\n") self.write("docs/plans/draft.md", "# Draft\n")