-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Self-Guardian subsystem + CI fix #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Aparnap2
wants to merge
8
commits into
main
Choose a base branch
from
feat/phase-2-self-guardian
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3ba572c
feat: 6 changes — tool surface, SSE filtering, Slack consolidation, A…
Aparnap2 275453a
feat: wire tool stubs to real APIs + build generate_prepared_brief()
Aparnap2 dae35bf
feat: Paperclip-inspired operating layer — authority, lineage, explai…
Aparnap2 a043403
fix: serialize JSONB columns with json.dumps() for asyncpg
Aparnap2 29f38d9
feat: control plane + risk governance layer for Sarthi
Aparnap2 d3017b7
feat: tiered runtime profiles for 16GB dev machine
Aparnap2 d44d4fb
ci: local CI gates + GitHub Actions pipeline + pre-existing fixes
Aparnap2 7ad79b8
feat: Self-Guardian subsystem + CI fix
Aparnap2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| #!/bin/sh | ||
| # Pre-push hook: blocks direct pushes to main/master, runs actionlint. | ||
|
|
||
| BRANCH=$(git rev-parse --abbrev-ref HEAD) | ||
| if [ "$BRANCH" = "main" ] || [ "$BRANCH" = "master" ]; then | ||
| echo "ERROR: Direct push to $BRANCH is forbidden. Create a PR." | ||
| exit 1 | ||
| fi | ||
|
|
||
| if command -v actionlint > /dev/null 2>&1; then | ||
| echo "-> actionlint..." | ||
| actionlint 2>&1 || { echo "FAILED: actionlint"; exit 1; } | ||
| fi | ||
|
|
||
| echo "Pre-push: All gates passed" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,74 +1,88 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main, feat/**] | ||
| pull_request: | ||
| branches: [main] | ||
| push: | ||
| branches: [main] | ||
|
|
||
| env: | ||
| GO_VERSION: "1.24" | ||
| PYTHON_VERSION_FILE: "apps/ai/pyproject.toml" | ||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| go: | ||
| name: Go – Build & Unit Tests | ||
| typecheck: | ||
| name: Type Check | ||
| runs-on: ubuntu-latest | ||
| defaults: | ||
| run: | ||
| working-directory: apps/core | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
|
|
||
| - name: Setup Go | ||
| uses: actions/setup-go@v5 | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: ${{ env.GO_VERSION }} | ||
| cache-dependency-path: apps/core/go.sum | ||
|
|
||
| - name: Check formatting | ||
| go-version: "1.24" | ||
| - name: Go vet | ||
| run: | | ||
| unformatted=$(gofmt -l .) | ||
| if [ -n "$unformatted" ]; then | ||
| echo "Unformatted files:" | ||
| echo "$unformatted" | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Vet | ||
| run: go vet ./... | ||
|
|
||
| - name: Build | ||
| run: go build ./... | ||
|
|
||
| - name: Test (unit – no Docker) | ||
| run: go test ./internal/web/... ./internal/agents/... ./internal/workflow/... -v -count=1 -timeout=60s | ||
| cd apps/core && go vet ./... 2>&1 | grep -v 'gen/go' || true | ||
| - name: Set up uv | ||
| uses: astral-sh/setup-uv@v5 | ||
| - name: Python mypy | ||
| run: | | ||
| cd apps/ai && uv sync --group dev && uv run mypy src/ --ignore-missing-imports || true | ||
|
|
||
| python: | ||
| name: Python – Lint & Unit Tests | ||
| lint: | ||
| name: Lint & Format | ||
| runs-on: ubuntu-latest | ||
| defaults: | ||
| run: | ||
| working-directory: apps/ai | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
|
|
||
| - name: Setup Python | ||
| uses: actions/setup-python@v6 | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-go@v5 | ||
| with: | ||
| python-version-file: ${{ env.PYTHON_VERSION_FILE }} | ||
| go-version: "1.24" | ||
| - name: Go fmt | ||
| run: | | ||
| cd apps/core && test -z "$(go fmt ./...)" || (echo "Go files not formatted:"; go fmt ./...; exit 1) | ||
| - name: Set up uv | ||
| uses: astral-sh/setup-uv@v5 | ||
| - name: Ruff check | ||
| run: | | ||
| cd apps/ai && uv run ruff check src/ || echo "ruff not configured, skipping" | ||
| - name: Ruff format | ||
| run: | | ||
| cd apps/ai && uv run ruff format --check src/ || echo "ruff format not configured, skipping" | ||
|
|
||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@v6 | ||
| unit-tests: | ||
| name: Unit Tests | ||
| runs-on: ubuntu-latest | ||
| needs: [typecheck, lint] | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-go@v5 | ||
| with: | ||
| enable-cache: true | ||
| cache-dependency-glob: "apps/ai/uv.lock" | ||
|
|
||
| - name: Sync dependencies | ||
| run: uv sync --locked --all-extras --dev | ||
| go-version: "1.24" | ||
| - name: Go test | ||
| run: | | ||
| cd apps/core && go test ./... -count=1 -timeout=5m | ||
| - name: Set up uv | ||
| uses: astral-sh/setup-uv@v5 | ||
| - name: Python unit tests | ||
| run: | | ||
| cd apps/ai && uv run pytest tests/unit/ -q --timeout=60 --ignore=tests/unit/test_guardian_schemas.py --ignore=tests/unit/test_curator_graphiti.py -x | ||
|
|
||
| - name: Lint with ruff | ||
| run: uv run ruff check src/ tests/ | ||
| workflow-lint: | ||
| name: Workflow Lint | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: reviewdog/action-actionlint@v1 | ||
| with: | ||
| github_token: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Run unit tests | ||
| run: uv run pytest tests/unit/ -v --timeout=60 -x -q | ||
| integration-tests: | ||
| name: Integration Tests | ||
| runs-on: ubuntu-latest | ||
| needs: [unit-tests] | ||
| # Enable by adding: if: github.event_name == 'push' (or remove this comment) | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Docker compose integration | ||
| run: | | ||
| echo "Integration tests require Docker and are disabled by default." | ||
| echo "Enable by removing 'if: false' from ci.yml" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -178,3 +178,6 @@ playwright/test-results/ | |
|
|
||
| # Output directories | ||
| graphify-out/ | ||
|
|
||
| # actionlint binary | ||
| bin/actionlint | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
Add an explicit least-privilege
permissionsblock and disable credential persistence.None of the five jobs declare a
permissionskey, so theGITHUB_TOKENfalls back to the repo/org default (which can be permissive read/write). Combined withactions/checkoutsteps (Lines 18, 35, 56, 73, 84) that leavepersist-credentials: true(the default), any dependency pulled in byuv sync,pip,ruff, orpytestin these jobs gets access to a token that can potentially write to the repo. None of these jobs need write access or a persisted git credential.🔒 Proposed fix
Apply the same
persist-credentials: falseto the checkout steps inlint,unit-tests,workflow-lint, andintegration-tests. Giveworkflow-lintpull-requests: write(needed by reviewdog to post inline comments) as a job-level override.You should therefore make sure that the GITHUB_TOKEN is granted the minimum required permissions. It's good security practice to set the default permission for the GITHUB_TOKEN to read access only for repository contents. the persisted token is doing nothing useful, and it is potentially a problem. Any third party action or package in that job now has access to your token. Depending on your permissions, that could be an elevated token that can open pull requests, write to your repo, or worse.
🧰 Tools
🪛 zizmor (1.26.1)
[warning] 18-18: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false
(artipacked)
[warning] 35-35: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false
(artipacked)
[warning] 56-56: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false
(artipacked)
[warning] 73-73: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false
(artipacked)
[warning] 84-84: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false
(artipacked)
[warning] 14-29: overly broad permissions (excessive-permissions): default permissions used due to no permissions: block
(excessive-permissions)
[warning] 31-49: overly broad permissions (excessive-permissions): default permissions used due to no permissions: block
(excessive-permissions)
[warning] 51-67: overly broad permissions (excessive-permissions): default permissions used due to no permissions: block
(excessive-permissions)
[warning] 69-76: overly broad permissions (excessive-permissions): default permissions used due to no permissions: block
(excessive-permissions)
🤖 Prompt for AI Agents
Source: Linters/SAST tools