Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
22 changes: 9 additions & 13 deletions docs/STYLE_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

<One or two sentences on what changes.>
<Which AI tool and model were used? Write "None" if no AI was used.>

## Why

<The problem or motivation.>

## Changes
## What changed

- <Observable change.>
- <Observable change.>

## Testing
## How verified

<Commands run and their result. Link to CI. No raw logs.>
<Commands run and their result. Explain any checks that could not run. No raw logs.>

## Risk and rollback
## Why

<Blast radius and how to revert.>
<The problem or motivation.>

## Breaking changes
## Risk

<What breaks and the migration. Write "none" if none.>
<Risk tier, affected paths, compatibility/operational impact, and rollback.>
```

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.
Expand Down
5 changes: 3 additions & 2 deletions docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand All @@ -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
Expand Down
15 changes: 11 additions & 4 deletions scripts/check_cross_repo_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
LINK = re.compile(r"\[[^\]]*\]\(([^)\s]+)\)")
# https://github.com/<owner>/<repo>/(blob|tree)/<ref>/<path>
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}")

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
45 changes: 33 additions & 12 deletions scripts/check_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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]")

Expand Down Expand Up @@ -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)

Expand Down
25 changes: 18 additions & 7 deletions scripts/test_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")))


Expand Down Expand Up @@ -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")
Expand Down
Loading