Skip to content

Commit 8ae9f1e

Browse files
committed
Add antigravity governance and token economy plan (Phase 12)
1 parent 0fa0302 commit 8ae9f1e

10 files changed

Lines changed: 358 additions & 10 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
name: ctxt-antigravity-governance
3+
summary: "Defines token-efficient governance and operating guidelines for agent runs."
4+
---
5+
6+
# Skill: ctxt-antigravity-governance
7+
8+
## Goal
9+
Enforce token-efficient context parsing, hook governance, permissions checks, and subagent boundaries during Antigravity agent execution.
10+
11+
## Read first
12+
- AGENTS.md
13+
- PROJEKT.md
14+
- docs/TOKEN_ECONOMY.md
15+
- docs/HOOK_GOVERNANCE.md
16+
- docs/SUBAGENT_GOVERNANCE.md
17+
18+
## Use when
19+
- Auditing agent task runs.
20+
- Defining permissions profiles or subagent boundaries.
21+
- Refining token usage and model effort guidelines.
22+
23+
## Forbidden
24+
- Reading `.env` or credentials files.
25+
- Dumping environment variables.
26+
- Performing live network calls without explicit phase authorization.
27+
- Writing outside the repository root.
28+
29+
## Validation
30+
- `cargo test`
31+
- `git diff --exit-code`
32+
33+
## Return
34+
Standard Phase Return Format.

PROJEKT.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ CompText CLI is an experimental terminal context client for building determinist
1919

2020
### Current State
2121
```text
22-
CURRENT_PHASE: 11
23-
CURRENT_TASK: Release Packaging
24-
LAST_GREEN_PHASE: 11
22+
CURRENT_PHASE: 12
23+
CURRENT_TASK: Antigravity CLI Governance & Token Economy
24+
LAST_GREEN_PHASE: 12
2525
STATUS: complete
2626
```
2727

@@ -86,8 +86,8 @@ git push
8686
| **Phase 9** | Validate and Benchmark | Local validation, dry-runs, and deterministic benchmark flows | **COMPLETE** |
8787
| **Phase 10** | MVP Stabilization & Release Readiness | Audit documentation, verify command flows, safety hygiene checks | **COMPLETE** |
8888
| **Phase 11** | Release Packaging | Package CLI binary, finalize manifests, release artifact generation | **COMPLETE** |
89-
| **Phase 12** | Antigravity CLI Governance & Token Economy | Hook, registry token bindings, runtime stake checks | *NEXT* |
90-
| **Phase 13** | Skill Bundle Registry | Distributed skills indexing and integrity hashing | *QUEUED* |
89+
| **Phase 12** | Antigravity CLI Governance & Token Economy | Hook, registry token bindings, runtime stake checks | **COMPLETE** |
90+
| **Phase 13** | Skill Bundle Registry | Distributed skills indexing and integrity hashing | *NEXT* |
9191
| **Phase 14** | Hook/Permission Integration | Hook boundaries, dynamic run approvals | *QUEUED* |
9292
| **Phase 15** | Cryptographic Provenance Engine | Signed evidence trail generation and cryptographic integrity seals | *QUEUED* |
9393

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ CompText is for developers who want AI-assisted workflows with stronger boundari
8585

8686
```text
8787
Binary: ctxt
88-
Current phase: Phase 11
89-
Current task: Release Packaging
90-
Last green phase: Phase 11
88+
Current phase: Phase 12
89+
Current task: Antigravity CLI Governance & Token Economy
90+
Last green phase: Phase 12
9191
Status: complete
9292
```
9393

@@ -108,13 +108,13 @@ Phase 8 OpenAI-Compatible Adapter COMPLETE
108108
Phase 9 Validate and Benchmark COMPLETE
109109
Phase 10 MVP Stabilization & Release Readiness COMPLETE
110110
Phase 11 Release Packaging COMPLETE
111+
Phase 12 Antigravity CLI Governance & Token Economy COMPLETE
111112
```
112113

113114
Next areas:
114115

115116
```text
116-
Phase 12 Antigravity CLI Governance & Token Economy NEXT
117-
Phase 13 Skill Bundle Registry QUEUED
117+
Phase 13 Skill Bundle Registry NEXT
118118
Phase 14 Hook/Permission Integration QUEUED
119119
Phase 15 Cryptographic Provenance Engine QUEUED
120120
```
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Antigravity CLI Integration Model
2+
3+
This document outlines the integration architecture and operational boundaries between the **Antigravity Framework** (the Agent Execution Surface) and the **CompText CLI** (the Context, Policy, and Evidence Control Plane).
4+
5+
---
6+
7+
## 1. Core Doctrine
8+
9+
CompText operates under a strict separation of concerns between agent execution and context governance:
10+
11+
- **Antigravity CLI is the Agent Execution Surface**: Handles task orchestration, command execution, tool invocations, and subagent lifecycle management.
12+
- **CompText CLI (`ctxt`) is the Context, Policy, and Evidence Control Plane**: Manages deterministic context packaging, proposal audits, file-write validation gates, and safety constraints.
13+
- **Skills are progressive context-loading capsules**: Bounded guidelines designed to prevent context bloat and restrict agent operations.
14+
- **Hooks are policy-interceptor targets**: Structural interception points allowing verification before, during, and after agent activities.
15+
- **Permissions are defense-in-depth, not the source of truth**: Hard platform sandboxing boundaries that back up (but do not replace) the repository safety constitution.
16+
- **Subagents are bounded specialist reviewers**: Highly targeted, read-only assistants delegated for review rather than autonomous development.
17+
- **The source of truth remains the code repository**: Safety constitution (`AGENTS.md`), project tracker (`PROJEKT.md`), CompText configurations, the Proposal/Apply Gate, and local validation commands.
18+
19+
---
20+
21+
## 2. Structural Interaction
22+
23+
```mermaid
24+
flowchart TD
25+
subagent[Antigravity Subagent]
26+
agent[Antigravity Orchestrator]
27+
ctxt[CompText CLI]
28+
repo[(Repository Codebase)]
29+
policy[Policy Gate / Hook]
30+
31+
agent -->|1. context inspect| ctxt
32+
ctxt -->|2. harvest & redact| repo
33+
ctxt -->|3. pack latest| pack[.comptext/context_pack.latest.json]
34+
agent -->|4. propose| ctxt
35+
ctxt -->|5. write proposal| prop[proposals/proposal.latest.json]
36+
agent -->|6. invoke reviewer| subagent
37+
subagent -->|7. audit proposal| prop
38+
agent -->|8. apply gate| ctxt
39+
ctxt -->|9. policy hook validation| policy
40+
policy -->|10. sandboxed commit| repo
41+
```
42+
43+
---
44+
45+
## 3. Operational Flow
46+
47+
1. **Context Harvesting**: Before launching a task, the Antigravity Orchestrator executes `ctxt context pack --task "<task_description>"`. This harvest sanitizes the repository state, redacting secrets and building a deterministic Context Pack under `.comptext/context_pack.latest.json`.
48+
2. **Proposal Generation**: When proposing changes, the agent runs `ctxt propose --provider dummy "<prompt>"`. This creates a structured JSON patch proposal under `proposals/` without mutating source files.
49+
3. **Apply and Verification**: To modify the codebase, the agent calls `ctxt apply <proposal_path>`. The CompText control plane intercepts the request, validates that target files lie within allowed write boundaries, prompts for user confirmation (or validation suite success), applies the patches, and runs local tests.

docs/HOOK_GOVERNANCE.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Hook Governance Model
2+
3+
Hooks are policy-interceptor targets designed to enforce strict safety boundaries before, during, and after agent runs. This document defines the target architecture for interceptor hooks within the CompText workspace.
4+
5+
---
6+
7+
## 1. Interception Points
8+
9+
The target architecture defines four critical interceptor locations:
10+
11+
```text
12+
[ SessionStart Hook ]
13+
14+
15+
[ PreToolUse Hook ] ────( Violations? )────► [ FAIL CLOSED / HALT ]
16+
17+
18+
( Tool Run )
19+
20+
21+
[ PostToolUse Hook ] ───( Redact Secrets )──► [ Filtered Context ]
22+
23+
24+
[ PostPhase Hook ] ─────( Cargo Validation )──► [ Git Commit Pipeline ]
25+
```
26+
27+
1. **SessionStart**:
28+
- **Trigger**: Executed when a new agent session or subagent run is initiated.
29+
- **Verification**: Parses workspace config, verifies CLI version, and checks that `AGENTS.md` and `PROJEKT.md` match remote origin main branches.
30+
2. **PreToolUse**:
31+
- **Trigger**: Executed immediately before any tool (e.g. file read, file write, shell command execution) is run.
32+
- **Verification**: Evaluates inputs against active policy rules. Fails closed and blocks execution if a violation is detected.
33+
3. **PostToolUse**:
34+
- **Trigger**: Executed immediately after a tool finishes running, before returning the output to the agent's context.
35+
- **Verification**: Filters and redacts high-entropy secrets, passwords, or credentials from command output and file read buffers.
36+
4. **PostPhase**:
37+
- **Trigger**: Executed when an agent signals completion of a roadmap phase.
38+
- **Verification**: Runs the **Global Validation Suite** and checks git status to ensure the working tree remains clean before triggering the git push progression pipeline.
39+
40+
---
41+
42+
## 2. Policy Enforcements
43+
44+
The hook governance architecture must actively enforce the following rules:
45+
46+
- **Block `.env` and Secret Reads**: PreToolUse hooks block attempts to read `.env`, `.env.*`, keyfiles (`*.key`, `*.pem`, `*.p12`, `*.pfx`), or private keys.
47+
- **Block Environment Variable Printing**: Blocks executing commands like `env`, `printenv`, or `Get-ChildItem Env:` to prevent leakages of system configuration credentials.
48+
- **Block Network and Provider Calls**: Intercepts socket calls or provider invocations unless the active phase config explicitly permits network access.
49+
- **Block Out-of-Bounds Writes**: Restricts file modifications to paths inside the repository root. Rejects edits targeting directories outside the workspace.
50+
- **Block Broad Repository Rereads**: Limits tool executions that read the entire codebase recursively unless justified by a phase transition.
51+
- **Require Proposal Before Apply**: Enforces that source code modification is only done via the `ctxt apply` flow referencing a verified JSON proposal from `proposals/`.
52+
- **Require Local Validation**: Blocks marking a phase as complete until all commands in the validation suite pass successfully.

docs/PERMISSIONS_MODEL.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Permissions Model
2+
3+
CompText utilizes a defense-in-depth permissions model to restrict agent actions at the operating system and execution environment level.
4+
5+
---
6+
7+
## 1. Defense-in-Depth Doctrine
8+
9+
Permissions do not serve as the primary policy compiler. Instead, they act as low-level guards supporting the Safety Constitution (`AGENTS.md`):
10+
11+
1. **Safety Constitution (`AGENTS.md`)**: The primary rulebook governing logical behavior.
12+
2. **Hook Interceptors (`docs/HOOK_GOVERNANCE.md`)**: Contextual software gates executing within the workspace.
13+
3. **Permissions Model**: Hardware/runtime restrictions enforced by the orchestration host.
14+
15+
If a hook fails or an agent attempts to bypass logical constraints, the permissions model catches the violation and halts the execution thread.
16+
17+
---
18+
19+
## 2. Permission Scopes
20+
21+
The active execution environment is partitioned into narrow permission scopes:
22+
23+
- **Read Access**: Restricted to the repository workspace directory. Reading files under `/etc`, `C:\Windows`, system temp directories, or user home directories (outside the workspace) is denied by default.
24+
- **Write Access**: Restricted to allowed targets within the workspace. Writing to system folders or configuration targets outside the project root is denied.
25+
- **Network Access**: Denied by default. Enforces blockades on remote socket connections.
26+
- **Provider Access**: Denied by default. Enforces blockades on calling external LLM providers or remote endpoints unless the phase explicitly authorizes mock or local integrations.
27+
28+
---
29+
30+
## 3. Explicit Phase Approval
31+
32+
If a task requires a restricted operation (e.g., querying a local Ollama socket), the permissions must be upgraded using explicit, phase-scoped approvals in the task definition. Once the phase transitions, permissions automatically downgrade back to the default-deny baseline.

docs/SKILL_AUTHORING_GUIDE.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Skill Authoring Guide
2+
3+
Skills are progressive context-loading capsules that guide agent behavior for specific phases or architectural boundaries. This document outlines the structure, syntax, and registry rules for creating new skills.
4+
5+
---
6+
7+
## 1. Skill File Layout
8+
9+
Every skill must live in the `.agent/skills/` (or `.agents/skills/`) directory as a markdown file structured as:
10+
11+
```markdown
12+
---
13+
name: ctxt-phase-XX-name
14+
summary: "A brief 1-line description of the skill for the compatibility manifest."
15+
---
16+
17+
# Skill: ctxt-phase-XX-name
18+
19+
## Goal
20+
The exact objective this skill is authorized to accomplish.
21+
22+
## Read first
23+
List of absolute or workspace-relative file links that the agent must read before executing any task under this skill.
24+
25+
## Use when
26+
Explicit description of triggers, keywords, or phase constraints under which this skill is active.
27+
28+
## Forbidden
29+
Concrete list of actions, commands, and files that are strictly banned while this skill is active.
30+
31+
## Validation
32+
Command sequence required to verify task completeness.
33+
34+
## Return
35+
The requested response format (e.g., standard status report schema).
36+
```
37+
38+
---
39+
40+
## 2. YAML Trigger Tracing
41+
42+
Triggers in the YAML frontmatter inform the Antigravity Orchestrator when a skill is relevant. Triggers are resolved from:
43+
- The **task description** matching the skill `name` or `summary`.
44+
- Active **phase declarations** (e.g., `Phase 12`).
45+
46+
---
47+
48+
## 3. Naming Conventions
49+
50+
To keep the registry consistent, all skill filenames and YAML names must follow one of these patterns:
51+
52+
- `ctxt-phase-XX-*`: Mapped to a specific sequential phase in the project state machine (e.g., `ctxt-phase-12-antigravity-governance`).
53+
- `ctxt-security-review`: General security review and claims validation.
54+
- `ctxt-release-packaging`: Build verification and release checklist validation.
55+
- `ctxt-antigravity-governance`: Governance policy auditing.
56+
57+
---
58+
59+
## 4. Required Content Sections
60+
61+
1. **Goal**: Must be concrete and bounded (no vague goals like *"Improve code"*).
62+
2. **Read first**: Must list the files representing the source of truth for the task (e.g., `AGENTS.md`, `PROJEKT.md`).
63+
3. **Use when**: Must describe the precise phase state.
64+
4. **Forbidden**: Must list global rules (e.g., *no network*, *no .env reads*) and task-specific constraints.
65+
5. **Validation**: Must include standard local commands (`cargo check`, `cargo test`, etc.).
66+
6. **Return**: Must match the standard schema declared in `AGENTS.md`.

docs/SUBAGENT_GOVERNANCE.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Subagent Governance Model
2+
3+
Subagents allow parallel task execution and validation. To prevent recursive execution issues or safety bypasses, subagents are subject to strict governance boundaries.
4+
5+
---
6+
7+
## 1. Allowed Roles
8+
9+
Only the following specialist subagent roles are permitted in the CompText workspace:
10+
11+
- **`security-reviewer`**: Audits codebase modifications and document updates for secret leakage, credentials, and forbidden compliance claims.
12+
- **`ci-diagnoser`**: Analyzes Cargo compilation failures, clippy warnings, or test logs, and recommends precise, localized corrections.
13+
- **`docs-consistency-checker`**: Audits documentation links, checks for file presence, and verifies README consistency.
14+
- **`proposal-auditor`**: Reviews proposal JSON structures before apply gate execution, confirming target write path safety.
15+
16+
---
17+
18+
## 2. Structural Constraints
19+
20+
- **Read-Only Baseline**: Subagents are read-only by default. They are authorized to search and inspect files but are strictly denied write access to the repository unless explicitly authorized for a highly specific, localized task.
21+
- **No Git Commit or Push Authority**: Subagents must never stage, commit, or push changes to Git. Only the primary orchestrator holds Git progression authority.
22+
- **No Autonomous Feature Building**: Subagents are bounded specialist validators. They are prohibited from writing new features, modifying program logic, or creating new provider adapters.
23+
- **Inherited Boundaries**: Subagents inherit the parent agent's configuration, including network blockades, secret redaction policies, and stop conditions. They must never be used to circumvent parental sandboxes.

docs/TOKEN_ECONOMY.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Token Economy Guidelines
2+
3+
To maintain long-running, safe autonomous development, CompText enforces a token-efficient operating model. Large context windows introduce noise, increase costs, and degrade model reasoning capabilities. Bounding the context size is a core safety control.
4+
5+
---
6+
7+
## 1. Context Minimization Principles
8+
9+
- **Read-First Minimalism**: The agent must read only the files declared in the `Read first` section of the active skill. Bulk directory reads or loading file logs outside the active scope are prohibited.
10+
- **One-Skill-at-a-Time Loading**: Only the single skill matching the active phase should be loaded into the workspace context. Loading multiple skills simultaneously causes instruction interference and unnecessary token consumption.
11+
- **No Repo-Wide Rereads Without Justification**: Repeating full context pack harvests (e.g., `ctxt context pack`) is permitted only when source files have changed or a new task boundary is crossed.
12+
- **Compact Phase Reports**: Status reports in the `reports/` folder must remain structured and concise. Avoid dumping complete compilation outputs, test outputs, or whole files. Summarize verification command results in a few clear bullet points.
13+
- **Session State Tracking**: The file `.comptext/session_state.md` is designated as the temporary local runtime session cache. This file is ignored by Git and is used to store active task notes, remaining token counts, and session progress metrics.
14+
15+
---
16+
17+
## 2. Model Effort Selection
18+
19+
To optimize costs and reasoning depths, the orchestrator should select model efforts based on task complexity:
20+
21+
| Complexity / Task Type | Target Model Effort | Description |
22+
|---|---|---|
23+
| **Low** / Syntax, Formatting, Clippy fixes | **Medium Effort** | Use for minor document cleanups, format checking, running local cargo checks, or generating release metadata. |
24+
| **High** / Structural Code, Merge Resolving, Security Auditing | **High Effort** | Use for resolving Git merge conflicts, reconciling branched PR states, running security/credential scans, or verifying critical provider adapter boundaries. |
25+
26+
---
27+
28+
## 3. Skill-Based Prompt Referencing
29+
30+
Instead of repeating long, descriptive instructions inside the agent's chat window prompts, prompts should reference skills directly:
31+
32+
- **Reference Syntax**: *"Load and execute skill `ctxt-phase-XX-name` by reading `file:///.agent/skills/ctxt-phase-XX-name/SKILL.md`."*
33+
- **Reasoning**: This offloads instruction formatting from the central chat context, ensuring the model references the precise skill markdown file statically rather than bloating the conversation transcript.

0 commit comments

Comments
 (0)