Repository navigation
Bootstrap posture: LICENSE, SECURITY, CODEOWNERS, validate check, pytest suite - #1
Conversation
…est suite Adds the day-one posture this public leg needs, per openxFactory openspec/changes/split-opendox-two-layer-product/tasks.md § 1.3-1.5: the Apache-2.0 LICENSE text, a SECURITY.md pointing reporters at GitHub's private vulnerability-reporting form, .github/CODEOWNERS routing review to @brettheap, a `validate` required check (pytest), and a real pytest suite asserting the shape. README gains a Posture section pointing at the assembly root's CONTRIBUTING.md and CODE_OF_CONDUCT.md. Lane: openxfactory-4-opendox-extraction Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011HB5MkaME9RsTPctRtYQ4a
There was a problem hiding this comment.
Sorry @brettheap, you've used your own review budget of 250,000 diff characters for the last 7 days.
You can request another review in 12 hours and 9 minutes by commenting @sourcery-ai review. Upgrade to get a review now.
Reviewer's GuideBootstraps the public openDox-code leg with Apache licensing, private security-reporting guidance, ownership and policy links, plus a required Python 3.12 pytest validation workflow. The new shape-focused test suite codifies the expected repository files, Apache license marker, and src/ role directory. Flow diagram for the repository validation postureflowchart LR
PullRequest[Pull request] --> Validate[validate workflow]
Validate --> Python[Python 3.12]
Python --> Pytest[python -m pytest -q]
Pytest --> ShapeTests[tests/test_leg_shape.py]
ShapeTests --> Result[Required check result]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
🟡 Changes recommended
The new GitHub Actions workflow should set explicit least-privilege permissions (and ideally pin pytest) to avoid overly broad token scopes and reduce CI fragility.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR establishes baseline “day-one” public-project posture for the openDox-code leg by adding governance/security documentation, CODEOWNERS routing, a CI validate workflow, and a minimal pytest suite that asserts the repository’s expected shape.
Changes:
- Add repository posture files: Apache-2.0
LICENSE,SECURITY.md, and.github/CODEOWNERS. - Add GitHub Actions
validateworkflow to runpytest. - Add
tests/test_leg_shape.pyand updateREADME.mdwith a Posture section linking to assembly-root policies.
File summaries
| File | Description |
|---|---|
tests/test_leg_shape.py |
Adds pytest checks asserting required posture files exist and that the repo has the expected role directory (src/). |
SECURITY.md |
Documents private vulnerability reporting via GitHub Security Advisories and scopes policy to this repo. |
README.md |
Adds “Posture” section pointing to assembly-root CONTRIBUTING / Code of Conduct and local SECURITY policy. |
LICENSE |
Adds canonical Apache License 2.0 text. |
.github/workflows/validate.yml |
Introduces CI job to run pytest on PRs and manual dispatch. |
.github/CODEOWNERS |
Sets default review routing to @brettheap. |
Review details
- Files reviewed: 6/6 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| name: validate | ||
|
|
||
| on: | ||
| pull_request: | ||
| workflow_dispatch: | ||
|
|
There was a problem hiding this comment.
Fixed in f8e88ae: added workflow-level permissions: contents: read.
| - name: install pytest | ||
| run: python -m pip install pytest |
There was a problem hiding this comment.
Fixed in f8e88ae: pinned to pytest>=8,<9.
Adds `permissions: contents: read` at the workflow level (this job only checks out and runs pytest, so the default token scope was broader than needed) and pins the pytest install to `>=8,<9` so a new pytest major release cannot break CI unannounced. Lane: openxfactory-4-opendox-extraction Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011HB5MkaME9RsTPctRtYQ4a
- use the literal ruleset enforcement values (`evaluate`/`active`) in the section header, matching the API/UI field values used in the body text - name the exact command used to establish that classic branch protection was never configured, since this file is itself serving as evidence - PR #1's body is now actually corrected (this PR's own comment thread), so the doc's claim is true rather than forward-looking Lane: openxfactory-4-opendox-extraction Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011HB5MkaME9RsTPctRtYQ4a
* Enforce validate as a required status check (closes 1.5) tasks.md item 1.5 was never done in PR #1: no repository ruleset or branch protection named the `validate` check as required, so nothing actually gated a merge on it passing (the two org-wide rulesets only require a PR and a Copilot review). This adds a repository-level ruleset (id 22364973) requiring the `validate` status check on `main`, created in EVALUATE mode ahead of this PR and promoted to ACTIVE once `validate` reported on this PR's own head commit -- see docs/branch-protection.md for the full evidence line. Lane: openxfactory-4-opendox-extraction Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011HB5MkaME9RsTPctRtYQ4a * Fix Copilot review findings on the evidence doc - use the literal ruleset enforcement values (`evaluate`/`active`) in the section header, matching the API/UI field values used in the body text - name the exact command used to establish that classic branch protection was never configured, since this file is itself serving as evidence - PR #1's body is now actually corrected (this PR's own comment thread), so the doc's claim is true rather than forward-looking Lane: openxfactory-4-opendox-extraction Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011HB5MkaME9RsTPctRtYQ4a --------- Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
…se (#30) # The seven follow-ups openDox-code#26 registered rather than took § 3.6 landed with seven findings **registered**, because each of its batches had a scope the holder set. This is the act that takes them, one commit, one case each. **Every measurement here was made against a full checkout of `4f8ae01e`** — never by pointing `PYTHONPATH` at an old tree. `pyproject.toml` sets `[tool.pytest.ini_options] pythonpath = ["src"]` and pytest **prepends** it, so a `PYTHONPATH` "old head" proof silently measures the new code and the case passes for nothing. That trap is now written down in `docs/runtime.md` § 8, "Proving a regression case against an older head", because it is the one that leaves a regression test in the suite that never saw the regression. ## The seven, with where each came from | # | finding | origin | |---|---|---| | 1 | the served **DATABASE** has no non-secret declaration, only the served schema | A25-3's half-closed finding, registered on #26 as **ruled item 4** | | 2 | **S8544** — installs resolve whatever the index offers on the day they run | SonarCloud on #26 (advisory gate) | | 3 | `_found` wraps the pre-check and not the **act**: a deleted row is a 500 | Copilot on #26 at `db5197d0`, suppressed | | 4 | the long-needle **substring** rule refuses `passwordless`, `secretary` | Copilot on #26 at `db5197d0`, suppressed | | 5 | `write_back` reuses a **pathname** where the act holds a descriptor | Copilot on #26 at `4156f233` | | 6 | the store's guard cannot see a **whitespace-bearing** scp authority | measured on #26 while closing the printing half; registered there | | 7 | the repository **root** keeps `runtime init`'s umask-derived mode | registered on #26 as `local_git_adapter.py:465`; ruled "measure first" | ### 1. `OPENDOX_SERVED_DATABASE`, and four manifest edits A25-3's finding was that `config._refuse_two_dsns_that_select_different_schemas` can never fire in a shipped deployment: the Deployment holds the served DSN, the migration Job holds the migration one, and no workload holds both — so the migration container has to be **told** where the API reads. It was told the **schema**. It was not told the **database**, and that is the wider question: a schema comparison made in the wrong database compares two names that happen to agree, and **`dbname` may be omitted from a DSN entirely, in which case libpq defaults it to the connection USER** (measured for #25's two-DSN guard) — so two DSNs that look alike can select two databases without either one saying so. The consequence is A25-3's, one level up: DDL and a ledger applied to a database nothing serves, or **`runtime reset` dropping the six coordination tables of a database that was never this install's**. That verb cannot be undone. `refuse_a_database_the_api_will_not_read` compares the declaration with `current_database()` **before the ledger is bootstrapped** and **before the schema guard** — the wider question first, so the refusal names the database when both declarations are wrong — in all three acts: `apply()`, `migrate --plan`, `reset`. A **name and never a credential**, which is the whole reason a workload that must not hold the served DSN can be given it. Four manifest edits carry it: the configmap literal (`pg_database=`), the Job's env, compose's migrate service (from the same `.env` value the Postgres service creates), and `.env.example`. ### 2. S8544 — one measured dependency lock, read by all three installs `pyproject.toml` declares what this package **needs** and deliberately does not pin it; a library that pins its dependents' versions cannot be installed beside anything. The other half was missing: the required job, the DB-backed job and the runtime image each resolved whatever the index offered on the day they ran, so **the same commit tested twice is two different programs**. `constraints-cpython312-linux.txt` is the **resolved** set — generated in a clean venv on cpython 3.12 / linux, not written by hand, with the command to regenerate it in its own header — and it is passed with `-c` in all three places. A **constraints** file and not a requirements one: it pins what is installed and installs nothing, so the required job still installs `.[test]` **alone** and the FastAPI and psycopg entries simply do not apply there. It sits at the **repository root**, and that is load-bearing: `deploy/` holds the git-ignored `.env` that `.dockerignore` exists to keep out of the build context, so a lock living there would have meant a `!deploy…` re-inclusion — and the guard that no such rule exists is what keeps the filled-in `.env` at home. ### 3. `_found` around the act, not only the pre-check Both repository routes read the map row with `_found(...)` and then call the act, which takes the row `FOR UPDATE` **inside itself**. A row deleted between those two statements raised `identity.NotFoundError` past a handler that catches only `RepositoryActRefused` — **measured at `4f8ae01e` as an uncaught exception**, which is a 500 where this API documents 404. The same class as #25's round 10 on the draft-discard path, and the same repair: the translation belongs on the call that can raise it, not on a read taken beforehand. ### 4. A parameter name is judged by its words, plus one declared compound Whole-word matching answered `sslpassword` — libpq's own keyword — as innocent, so the first repair made every declared needle of six characters or more a **substring**. That bought one true name at the price of every other compound of those words: **measured**, `passwordless` and `secretary` were refused as credential-bearing. A false refusal at a **configuration** boundary is not the safe direction — this predicate decides whether an install starts. So the compound is **declared**, and there is exactly one this runtime meets. `credentials_version` stays refused **on purpose**: `credentials` is one of its words, and that same reading is what catches `access_token`, `X-Api-Key` and `sessionToken` — narrowing past it would mean comparing the whole name, which those three walk straight through. ### 5. The temporary index is written through the held descriptor Every other call in `write_back` goes through `-C /proc/self/fd/<n>`, which is what makes "the check and the use are one object" true. `GIT_INDEX_FILE` was built from `rev-parse --absolute-git-dir` — a **pathname**. **Measured on git 2.43.0**, with the directory renamed away and a symlink to a second repository put in its place after the probe: | form | where `opendox-index-…` landed | |---|---| | the absolute pathname | **the decoy** | | joined onto the held descriptor | the real repository | `--git-dir` asked through `-C` answers **relative** — `.` for the bare repository this act creates, `.git` for a checkout, both measured — so joining it onto the runner's own root keeps the whole path, and the `unlink` that cleans it up, inside the descriptor. The case drives the swap from the probe itself and asserts **both** the mechanism (the index path is inside `/proc/self/fd/`) and the consequence (the decoy holds nothing, the real repository holds the commit); against `4f8ae01e` it reports the absolute path. ### 6. The store names an authority it cannot read `_scp_like_userinfo` declines a head holding whitespace so this rule cannot start judging prose, and the redactor's `_CREDENTIAL_SHAPED` excludes it so an unrelated `user@host` three lines down git's stderr is not joined to the URL above it — and `user:pa ss@host:path` sat between them: refused in its URL form, accepted in its scp form. #26 closed the printing half at the one-URL entry point; this closes the store's own guard, **by shape and never by value**, on `_split_url`'s reasoning that a value this module cannot parse can still carry a credential. Nothing ordinary is caught: a head without `:` is a username, a value without `@` has no authority, and `/srv/a@b/my repos/x.git` is neither. ### 7. The repository root is created 0700 — measured first, as ruled The holder ruled "measure first, fix only if a reachable path leaves it wider than 0700". `runtime init` is that path: every repository under the root is created `REPOSITORY_DIRECTORY_MODE`, and the root **above** them took `Path.mkdir`'s default, `0o777 & ~umask`. **Measured**: 0755 under the container's own umask (0o022) and **0777 under umask 0** — every project id listable, and traversable, by any local account. `0o700` is umask-safe, because a umask can only remove bits, and `Path.mkdir` applies `mode` to the **leaf** only, which is right: the parents are the operator's own path components. An **existing** root is reported and not re-moded, on the walk's own rule that it narrows only what it made itself — an operator's mount point is not this act's to change — and the mode is in `init`'s evidence, so an operator upgrading from a build that created it 0755 sees the number and decides. ## Three existing cases moved with the code, and say why in place * the required job's install guard reads the `.[…]` **extras** now, rather than searching the whole command line for the word `runtime` — the lock's filename contains it, and what the job must not do is install the runtime **extra**; * the Dockerfile's install assertions read the parts rather than one exact line, because the install now carries `-c` and wraps; * the redactor/refusal corpus records that one of its two "hidden but not refused" shapes is now refused, leaving one — the double-encoded parameter name, which stays a deliberate difference because a server decodes a name **once**, so `?%74oken=` is the one that arrives as `token` and **is** refused. ## Measured (python 3.12.3, pytest 8.4.2, postgres 16.15, git 2.43.0) Every figure below was measured at **`4767ceb7`**, with the `runtime` extra made UNIMPORTABLE (the required job's own install) and with no ambient git configuration, and holds at the current head **`58852e1`**, which adds only the workflow's record of it. **This description is edited in the same act as that record**, which is what the round at `0a2af8b8` asked for on the sibling PR. The branch carries `origin/main` by **merge** (#29's "Pin the triple" step on the required job), never by rebase; both of this PR's hunks in that file — the two `-c` installs and the figure block — stayed where they were. | run | result | |---|---| | the required `validate` job's own invocation (`--noconftest`, the six hermetic modules) | **357 passed, 1 skipped** | | of which `tests_runtime/test_local_git_adapter.py` | 132 passed | | `tests_runtime/test_repository_act.py` (DB-backed) | 82 passed | | `python -m pytest -q tests_runtime/` with `OPENDOX_TEST_DATABASE_URL` set | **568 passed** | | `python -m pyflakes src/opendox/runtime/*.py tests_runtime/*.py` | clean | | the constrained install itself (`pip install -c … -e ".[test]"` in a clean venv) | 6 packages, and the hermetic six green under it | **Ten new cases, each run against `4f8ae01e` first**, and each failed there for its own reason: the uncaught `NotFoundError`, `MigrationRunner.__init__() got an unexpected keyword argument 'served_database'`, `0o777`, the absolute index path, the three refusals and the missing lock. ## The review at `4df3701c`, and what it moved Four findings, all measured true, all taken in one push — three of them defects in **this act's own output**, which is the line the holder drew: a finding about landed code is registered, work that does not do what it says is repaired. * **The same defect in both deployments: a declaration that defaults to EMPTY beside a server that CREATES a named database.** Compose declared `${OPENDOX_PG_DB:-}` next to `POSTGRES_DB: ${OPENDOX_PG_DB:-opendox}`; the Kubernetes base left `pg_database=` empty and **neither overlay set it** (measured: `dev` merges only `opendox-oidc`, `managed-database` merges `migration_wait_host` and a commented `runtime_pg_role`). So the guard item 1 exists to add was a **no-op in every shape that ships**. One expression for compose's two services now; the base declares `opendox`, which its own StatefulSet hardcodes; the managed-database overlay — which deletes that StatefulSet — carries the commented edit beside the one it already carries. Leaving it wrong there is a **refusal**, not a silent wrong-database migration. `pg_schema` stays empty for the opposite reason: `public` is PostgreSQL's default, not a name this repository chose. * **The image's repository root bypassed item 7.** `runtime init` narrows the root it *creates*, and in the shipped image it creates nothing — the Dockerfile makes `/var/lib/opendox/projects` in its own layer with `mkdir -p`, which takes `0o777 & ~umask` (0755 for a `RUN`), and this runtime does not re-mode a directory it did not make. `install -d -m 0700` states the mode itself, in the layer that owns the directory. * **The runbook's old-head procedure now runs as written** — `tar -x -C` does not create its destination. * **The comment at `local_git_adapter.py:2104` said something false, and now says the truth.** See follow-up #1 below. No behaviour changed there in this act. ## Registered as follow-up #1 — a separate PR, ruled **`write_back`'s index is still pathname-bound for a LINKED WORKTREE**, and the comment that denied it was wrong. **Measured on git 2.43.0:** `git -C <worktree> rev-parse --git-dir` answers the **absolute** `<main>/.git/worktrees/<name>` — not `.` or `.git` — and `test_a_linked_worktree_can_reach_its_write_path`, landed with § 3.6, serves exactly that shape **writable** and drives `write_back` through it. So the fallback branch is live for a supported corpus, and for it `GIT_INDEX_FILE` stays outside the held descriptor: the race this PR closes for a bare repository and a checkout remains open there. **Ruled by the holder**: bind the worktree's metadata by descriptor — its **own** gitdir *and* `--git-common-dir`, which is where `objects/` and `refs/` live, so two more held directories threaded through the method — and **keep linked worktrees writable**. Making them read-only instead is **rejected**, because it reverses a decision § 3.6 landed with its own case. A separate act, size M, not folded in here. ## Not in this act * **`local_git_adapter.py:465` is the one item that came back "measure, then decide"** and the decision is recorded above: `runtime init` is the reachable path and it is fixed; the walk's own `fchmod` was already correct, and a pre-existing root is reported rather than re-moded — with the image's own layer now making that root 0700, since it is the one place that owns it. * **Follow-up #1 above** — the linked worktree's index, ruled a separate act. * The SonarCloud findings that are **not** S8544 (cognitive complexity, duplicated literals, the `secrets:S8136` false positives on this repository's own redaction fixtures) are untouched; the gate is advisory here and they are not this act's list. Lane: openxfactory-4 (openXfactory-4-openDox_extraction) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Lane: openxfactory-4 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Lane: openxfactory-4-opendox-extraction (formerly openxfactory-opendox)
Adds the day-one posture this public leg needs, per openxFactory's
openspec/changes/split-opendox-two-layer-product/tasks.md§ 1.3-1.4: thecanonical Apache-2.0
LICENSEtext, aSECURITY.mdpointing reporters atGitHub's private vulnerability-reporting form (never a public issue),
.github/CODEOWNERSrouting review to@brettheap, avalidaterequiredcheck (pytest), and a real pytest suite (
tests/test_leg_shape.py)asserting the shape. README gains a Posture section pointing at the
assembly root's
CONTRIBUTING.mdandCODE_OF_CONDUCT.md.Refs opensoft/openXfactory#656
🤖 Generated with Claude Code
https://claude.ai/code/session_011HB5MkaME9RsTPctRtYQ4a
Summary by Sourcery
Establish the openDox code leg’s day-one public repository posture and automated validation.
Enhancements:
CI:
Documentation:
Tests:
Correction (added after merge): this PR's original body claimed "§ 1.3-1.5" compliance. That overstated the work -- item 1.5 (a branch-protection ruleset requiring the
validatecheck, EVALUATE then ACTIVE) was never done here; no ruleset existed in this repository until PR #2 (chore/enforce-validate-required-check), which closes 1.5 and documents the evidence indocs/branch-protection.md. This body is corrected to claim only § 1.3-1.4.