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
9 changes: 8 additions & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
# 🖋️ Contributing to Amrikyy Lab

## Sovereign Contribution Protocol
By contributing to **Amrikyy Lab**, you agree to transfer all IP to the Sovereign State of PiWorker-OS.

By contributing to **Amrikyy Lab**, you agree to transfer all IP to the Sovereign State of PiWorker-OS.

## Rules of Engagement

1. **Clean Room Only**: No legacy code or unauthorized logic extraction.
2. **Type Safety**: Strict TypeScript is the law.
3. **Sovereign Signature**: All commits must be signed.

---

**Amrikyy Lab :: Built for Independence**

## Security Governance

All contributors must follow `docs/operations/security-governance-policy.md` for PR security gates, backward compatibility/versioning, deprecation windows, and security SLA expectations.
13 changes: 12 additions & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ Fixes # (issue)

Before submitting, you **MUST** ensure the following. PRs failing these checks will be closed.

### 🔒 Mandatory Security Checklist (Required)

- [ ] **I confirm this PR passes dependency, secret, and static scans in CI (required).**
- [ ] **I confirm no hardcoded secrets/tokens/keys are introduced (required).**
- [ ] **I reviewed new/changed dependencies for risk and licensing impact (required).**
- [ ] **Any CRITICAL/HIGH findings are resolved or explicitly approved with SLA tracking (required).**

### Code Quality & Standards

- [ ] My code follows the **Clean Room Engineering** rules (no legacy copy-paste).
Expand All @@ -27,12 +34,16 @@ Before submitting, you **MUST** ensure the following. PRs failing these checks w
- [ ] My changes generate zero new TypeScript warnings or errors (`npm run typecheck`).
- [ ] Code is properly formatted (`npm run format` or via `lint-staged`).

### API / Proto Contract Safety

- [ ] If this PR changes API/proto contracts, contract tests are updated and passing in CI.
- [ ] If this PR changes an external interface, backward-compatibility policy is followed (versioning + deprecation window).

### Security & Architecture (PoPW & Sandbox)

- [ ] I have verified that this change does **not** break the Sandbox isolation boundaries.
- [ ] If this PR introduces an Architectural Decision, I have created/updated an ADR in `docs/architecture/adr/`.
- [ ] If this PR relates to physical work, it passes the Proof of Physical Work (PoPW) criteria.
- [ ] No hardcoded secrets or API keys (e.g., `GEMINI_API_KEY`) are included in this PR.

### Testing

Expand Down
79 changes: 40 additions & 39 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,33 @@ permissions:
contents: read

jobs:
changes:
name: Detect API/proto changes
runs-on: ubuntu-latest
outputs:
api_or_proto_changed: ${{ steps.filter.outputs.api_or_proto }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Filter paths
id: filter
uses: dorny/paths-filter@v3
with:
filters: |
api_or_proto:
- 'api/**'
- '**/*.proto'
- 'sidecar/sovereign-engine/pkg/pb/**'

build:
name: Build & Security Audit
runs-on: ubuntu-latest

steps:
- name: Checkout code
# Pin action versions to a vetted release tag for supply-chain security and reproducible runs.
uses: actions/checkout@v6
uses: actions/checkout@v4

- name: Setup Node.js
# Pin action versions to a vetted release tag for supply-chain security and reproducible runs.
uses: actions/setup-node@v4
with:
node-version: "22.x"
Expand All @@ -38,8 +54,7 @@ jobs:
run: npm run contracts:check

- name: Setup Go
# Pin action versions to a vetted release tag for supply-chain security and reproducible runs.
uses: actions/setup-go@v6
uses: actions/setup-go@v5
with:
go-version: "1.25.10"
cache-dependency-path: go.sum
Expand Down Expand Up @@ -69,8 +84,13 @@ jobs:
- name: Secret scan (Secretlint)
run: npx secretlint "**/*"

- name: Static scan (Semgrep)
run: |
python -m pip install --upgrade pip
pip install semgrep
semgrep --config p/owasp-top-ten --error
Comment on lines +87 to +91
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Semgrep version unpinned — undermines supply-chain security

pip install semgrep without a version specifier fetches whatever the latest PyPI release is at run time. This contradicts the supply-chain hardening intent of this PR: a new Semgrep release could silently change rule results, break the --config p/owasp-top-ten fetch, or introduce a dependency with a vulnerability. Pin a specific version to make the scan reproducible and auditable.

Suggested change
- name: Static scan (Semgrep)
run: |
python -m pip install --upgrade pip
pip install semgrep
semgrep --config p/owasp-top-ten --error
- name: Static scan (Semgrep)
run: |
python -m pip install --upgrade pip
pip install semgrep==1.100.0
semgrep --config p/owasp-top-ten --error

Fix in Conductor


- name: Vulnerability scan (Trivy)
# Pin action versions to a vetted release tag for supply-chain security and reproducible runs.
uses: aquasecurity/trivy-action@v0.24.0
with:
scan-type: fs
Expand All @@ -94,7 +114,7 @@ jobs:
## Build & verification matrix
- Node typecheck
- Go build (CLI + sovereign engine)
- Security scans (Secretlint + Trivy + govulncheck)
- Security scans (Secretlint + Semgrep + Trivy + govulncheck + npm audit)
- Targeted Performance SLO Profiling
- Contract Sync Validation
- Artifact sanity checks
Expand All @@ -104,51 +124,32 @@ jobs:
EOF2

- name: Upload release checklist artifact
# Pin action versions to a vetted release tag for supply-chain security and reproducible runs.
uses: actions/upload-artifact@v4
with:
name: release-checklist
path: release-checklist.md
if-no-files-found: error

e2e-real:
name: E2E Real (staging)
contract-tests:
name: Contract tests for API/proto changes
needs: changes
if: needs.changes.outputs.api_or_proto_changed == 'true'
Comment on lines +133 to +136
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 contract-tests runs independently of build, bypassing all security gates

The contract-tests job declares needs: changes but not needs: build. This means it can succeed (and satisfy its branch-protection check) even when the build job — which runs npm audit, govulncheck, Secretlint, Semgrep, and Trivy — is still running or has already failed. A PR that introduces a vulnerable dependency or a secret could pass the contract-tests gate before the build's security scans report failure, giving reviewers a false sense of passing CI for the security-sensitive contract path. Adding needs: [changes, build] would ensure contract tests only run against a clean, fully-audited build.

Fix in Conductor

runs-on: ubuntu-latest
needs: build
# This job is a blocker for main/release branches by failing hard when env/secrets are absent or tests fail.
if: github.event_name == 'pull_request' || startsWith(github.ref, 'refs/heads/main') || startsWith(github.ref, 'refs/heads/release/')
env:
SOVEREIGN_STAGING_URL: ${{ vars.SOVEREIGN_STAGING_URL }}
SOVEREIGN_AUTH_TOKEN: ${{ secrets.SOVEREIGN_AUTH_TOKEN }}
AGENT_SYSTEM_SECRET: ${{ secrets.AGENT_SYSTEM_SECRET }}

steps:
- name: Checkout code
uses: actions/checkout@v6

uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22.x"

- name: Install dependencies
run: npm install --ignore-scripts --no-audit --no-fund --legacy-peer-deps

- name: Validate required staging env
run: |
missing=0
[ -n "$SOVEREIGN_STAGING_URL" ] || { echo "Missing required var: SOVEREIGN_STAGING_URL"; missing=1; }
[ -n "$SOVEREIGN_AUTH_TOKEN" ] || { echo "Missing required var: SOVEREIGN_AUTH_TOKEN"; missing=1; }
[ -n "$AGENT_SYSTEM_SECRET" ] || { echo "Missing required var: AGENT_SYSTEM_SECRET"; missing=1; }
[ "$missing" -eq 0 ] || exit 1

- name: Run real E2E
run: npm run test:tier4

- name: Upload E2E artifacts
if: always()
uses: actions/upload-artifact@v4
- name: Contract sync check
Comment on lines 145 to +147
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 --no-audit skips dependency auditing in the contract-tests job

The contract-tests job installs dependencies with --no-audit, which suppresses npm audit output. This is inconsistent with the security intent of this PR — a PR touching API/proto surfaces is exactly the kind of change where dependency integrity should be verified. Consider dropping the flag or running a separate npm audit step after install.

Suggested change
- name: Install dependencies
run: npm install --ignore-scripts --no-audit --no-fund --legacy-peer-deps
- name: Validate required staging env
run: |
missing=0
[ -n "$SOVEREIGN_STAGING_URL" ] || { echo "Missing required var: SOVEREIGN_STAGING_URL"; missing=1; }
[ -n "$SOVEREIGN_AUTH_TOKEN" ] || { echo "Missing required var: SOVEREIGN_AUTH_TOKEN"; missing=1; }
[ -n "$AGENT_SYSTEM_SECRET" ] || { echo "Missing required var: AGENT_SYSTEM_SECRET"; missing=1; }
[ "$missing" -eq 0 ] || exit 1
- name: Run real E2E
run: npm run test:tier4
- name: Upload E2E artifacts
if: always()
uses: actions/upload-artifact@v4
- name: Contract sync check
- name: Install dependencies
run: npm install --ignore-scripts --no-fund --legacy-peer-deps
- name: Contract sync check

Fix in Conductor

run: npm run contracts:check
- name: Setup Go
uses: actions/setup-go@v5
with:
name: e2e-real-artifacts
path: tests/e2e/artifacts/
if-no-files-found: warn
go-version: "1.25.10"
cache-dependency-path: go.sum
- name: API package tests
run: go test ./api/...
Comment on lines 124 to +155
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 e2e-real staging job removed with no replacement

The entire e2e-real job — which ran npm run test:tier4 against a live staging environment, validated required env vars (SOVEREIGN_STAGING_URL, SOVEREIGN_AUTH_TOKEN, AGENT_SYSTEM_SECRET), and uploaded E2E artifacts — has been silently dropped. The new contract-tests job only performs a contract-sync check and go test ./api/..., and only triggers when api/** or *.proto files change. Any regression in non-API runtime behavior against staging will go undetected. If the removal is intentional, the PR description should justify it; otherwise this is a testing coverage gap.

Fix in Conductor

65 changes: 65 additions & 0 deletions docs/operations/security-governance-policy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Security Governance Policy

## 1) Scope

This policy applies to every pull request merged into `main`, including application code, infrastructure code, API/proto contracts, and CI/CD workflows.

## 2) Required PR Security Gates

Every PR MUST pass all of the following checks:

1. **Dependency scanning**
- `npm audit --audit-level=high --omit=dev`
- `govulncheck ./...`
2. **Secret scanning**
- `secretlint` and repository secret scanning workflow.
3. **Static analysis scanning**
- `semgrep --config p/owasp-top-ten --error`
4. **Filesystem vulnerability scanning**
- `trivy fs` (fail on `CRITICAL,HIGH`).

Any failing critical gate blocks merge.

## 3) Contract Tests for API/Proto Changes

For any PR that changes API or proto surface (e.g. `api/**`, `*.proto`, generated protobufs), contract tests are mandatory and must pass before merge.

## 4) Backward Compatibility Policy

### Versioning

- Public API/proto changes MUST follow semantic versioning principles:
- Backward-compatible additions: **minor** version bump.
- Breaking changes: **major** version bump.

### Deprecation window

- Deprecated fields/endpoints/RPCs must remain supported for at least **90 days** after deprecation notice.
- Deprecation notices must include:
- exact deprecation date,
- planned removal date,
- migration path.

### Breaking-change controls

- Breaking changes require:
- explicit approval from maintainers,
- migration notes in release artifacts,
- validation that consumers have a migration path.

## 5) Critical Findings SLA & Monitoring

### SLA

- **CRITICAL findings:** remediation or approved compensating control within **24 hours**.
- **HIGH findings:** remediation within **7 calendar days**.

### Monitoring & closure

- Security findings from CI/security tools must be triaged on every PR.
- Unresolved findings must be tracked with owner + due date.
- PRs introducing unapproved CRITICAL findings must not merge.

## 6) Exceptions

Any policy exception must include written risk acceptance, compensating controls, and an expiry date approved by maintainers.
Loading