dsh-inkstone-agent 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +71 -0
- package/LICENSE +21 -0
- package/README.md +309 -2
- package/README.zh.md +315 -0
- package/cordis.patch.yml +3 -0
- package/docs/TUTORIAL.md +285 -0
- package/docs/TUTORIAL.zh.md +314 -0
- package/icon.svg +7 -0
- package/lib/index.js +8126 -0
- package/lib/types/challenge/challenge-registry.d.ts +114 -0
- package/lib/types/changeset/change-set.d.ts +60 -0
- package/lib/types/changeset/integration.d.ts +41 -0
- package/lib/types/changeset/worktree.d.ts +74 -0
- package/lib/types/config.d.ts +49 -0
- package/lib/types/confinement/handback-broker.d.ts +32 -0
- package/lib/types/confinement/redactor.d.ts +17 -0
- package/lib/types/confinement/rollback-engine.d.ts +74 -0
- package/lib/types/confinement/sensitive.d.ts +5 -0
- package/lib/types/confinement/snapshot-ledger.d.ts +127 -0
- package/lib/types/confinement/write-guard.d.ts +99 -0
- package/lib/types/evidence/completion-gate.d.ts +35 -0
- package/lib/types/evidence/policy-file.d.ts +29 -0
- package/lib/types/evidence/providers.d.ts +52 -0
- package/lib/types/evidence/runner.d.ts +25 -0
- package/lib/types/evidence/store.d.ts +50 -0
- package/lib/types/evidence/types.d.ts +70 -0
- package/lib/types/hooks/model-tools.d.ts +53 -0
- package/lib/types/hooks/pre-step.d.ts +26 -0
- package/lib/types/hooks/tool-pipeline.d.ts +38 -0
- package/lib/types/hooks/user-commands.d.ts +61 -0
- package/lib/types/immune/experience-distiller.d.ts +48 -0
- package/lib/types/immune/experience-scoring.d.ts +50 -0
- package/lib/types/immune/experience-store.d.ts +51 -0
- package/lib/types/index.d.ts +66 -0
- package/lib/types/kernel/authority-kernel.d.ts +136 -0
- package/lib/types/kernel/decisions.d.ts +51 -0
- package/lib/types/kernel/event-log.d.ts +44 -0
- package/lib/types/kernel/grants.d.ts +105 -0
- package/lib/types/kernel/path-match.d.ts +20 -0
- package/lib/types/kernel/policy.d.ts +37 -0
- package/lib/types/kernel/state-store.d.ts +23 -0
- package/lib/types/locales/index.d.ts +173 -0
- package/lib/types/mandate/impact-analyzer.d.ts +48 -0
- package/lib/types/mandate/mandate-registry.d.ts +48 -0
- package/lib/types/mandate/symbol-graph.d.ts +120 -0
- package/lib/types/tribunal/deadlock-watchdog.d.ts +57 -0
- package/lib/types/tribunal/machine-verifier.d.ts +52 -0
- package/lib/types/tribunal/readonly-reviewer.d.ts +77 -0
- package/lib/types/tribunal/tribunal-gate.d.ts +121 -0
- package/lib/types/types.d.ts +454 -0
- package/locale/en.json +33 -0
- package/locale/zh.json +33 -0
- package/package.json +92 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `dsh-inkstone-agent` will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.1.0] - 2026-11-10
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **Deterministic Authority Kernel (L2)** (`src/kernel/`):
|
|
15
|
+
- Persistent `Grant` registry with an append-only JSONL event log (`authority.jsonl`) and per-record SHA-256 hash chaining for tamper detection.
|
|
16
|
+
- Multi-workspace isolation, restart recovery, and audit records (`DecisionRecord`).
|
|
17
|
+
- Effective write authority computed as strict intersection: `Host Sandbox Root ∩ Effective Grant ∩ Task writeScopes`.
|
|
18
|
+
- **Team Task Interception & Anti-Escalation**:
|
|
19
|
+
- `team_task_create` with write scopes by a teammate is denied (`INKSTONE_SCOPE_DELEGATION_REQUIRED`).
|
|
20
|
+
- Task owner editing its own task scopes may only narrow (`INKSTONE_SCOPE_ESCALATION` otherwise); only Lead edits issue grants.
|
|
21
|
+
- Sensitive files (`.env*`, `*.pem`, `*.key`, `.npmrc`, `id_rsa`, configs with secrets) cannot be delegated through tasks (`INKSTONE_SENSITIVE_SCOPE`).
|
|
22
|
+
- **Transactional Snapshots & Atomic Rollback**:
|
|
23
|
+
- Byte-exact before/after snapshots for every write tool call (text stored as-is, binary stored as Base64).
|
|
24
|
+
- 1 MiB truncation safety guard (`ROLLBACK_TRUNCATED`): files exceeding limit record SHA-256 only and prevent erroneous blanking upon rollback.
|
|
25
|
+
- Pre-rollback after-state conflict verification against current disk content (`ROLLBACK_CONFLICT`).
|
|
26
|
+
- Human-only `--force` option to override disk conflicts (`/rollback <target> --force`).
|
|
27
|
+
- Automated secret and credential redaction (`[REDACTED]`) in `tools/post-execute`.
|
|
28
|
+
- **AST Architecture Perception & Contract Handback (L1)** (`src/mandate/`):
|
|
29
|
+
- `SymbolGraph` and `ImpactAnalyzer` traversing 1–2 hop upstream/downstream call closures (`resolved` and `probable` edges).
|
|
30
|
+
- Automated detection of broken upstream callers when exported function/interface signatures change.
|
|
31
|
+
- `mandate_handback` tool: transforms out-of-scope write attempts into structured change requests routed to file owners via `ctx.agentTeams.sendMessage` (messages convey zero authority).
|
|
32
|
+
- **Zero-Trust Tribunal Gate & Attention Firewall (L3)** (`src/tribunal/`, `src/evidence/`):
|
|
33
|
+
- Interception of `team_task_update(action: 'complete')`.
|
|
34
|
+
- Multi-provider objective evidence gathering: human verification policy (`.inkstone.policy.json`), snapshot integrity, Git conflict markers (`<<<<<<<`), strict JSON/JSONC parsing, protected file checks, and AST caller consistency.
|
|
35
|
+
- Hash-bound human approval via `/inkstone-approve [reason]`; subsequent writes invalidate earlier approvals.
|
|
36
|
+
- `DeadlockWatchdog`: computes failure fingerprints and halts automated retries after `maxTribunalRejections` (default 2), escalating to a 3-choice human attention dialog.
|
|
37
|
+
- 10-minute timeout for human attention prompts; unanswered or skipped dialogs trigger defensive task termination.
|
|
38
|
+
- **On-Demand Challenge Tasks (M4, Experimental)** (`src/challenge/`):
|
|
39
|
+
- Lead-opened challenges bound to specific ChangeSet content hashes.
|
|
40
|
+
- Finding lifecycle (`open` → `reproduced` → `fixed` → `close`), submitted strictly with counterexamples and reproduction steps; findings block completion.
|
|
41
|
+
- **C4 Cross-Session Self-Evolving Immune Memory (L4)** (`src/immune/`):
|
|
42
|
+
- High-signal experience distillation from tribunal recoveries and human `/rollback` interventions.
|
|
43
|
+
- Mathematical dynamic scoring with validations boost, time decay, misleading penalties, and Jaccard clustering ($\ge 0.6$).
|
|
44
|
+
- Automatic injection of historical risk cues into prompt context during `agent/pre-step`.
|
|
45
|
+
- **Interactive Commands & Tools**:
|
|
46
|
+
- Human slash commands: `/changes`, `/rollback`, `/mandate`, `/inkstone-approve`, `/immune`.
|
|
47
|
+
- Model autonomous tools: `mandate_analyze`, `mandate_handback`, `tribunal_verify`, `inkstone_rollback`, `inkstone_worktree`, `inkstone_integrate`, `inkstone_challenge`.
|
|
48
|
+
- **Documentation & Workflows**:
|
|
49
|
+
- Comprehensive, standalone bilingual in-depth workflow tutorials: `docs/TUTORIAL.zh.md` and `docs/TUTORIAL.md`.
|
|
50
|
+
- Copy-paste ready `.inkstone.policy.json` templates for TypeScript, Python, and Rust/Go projects with executable allow-list specifications.
|
|
51
|
+
- Added `"docs/*.md"` to `package.json` package files list.
|
|
52
|
+
|
|
53
|
+
### Changed
|
|
54
|
+
|
|
55
|
+
- **Host-Only Architecture**: Fully converted into a host-only DSH plugin with zero client bundle footprint; UI elements rely on DSH native rendering.
|
|
56
|
+
- **Simplified Settings Schema**: Consolidated settings into three top-level master switches (`confinementEnabled`, `tribunalEnabled`, `immuneMemoryEnabled`) with secure defaults.
|
|
57
|
+
- **Model Review Off Critical Path**: `tribunalModelReviewEnabled` defaults to `false` and acts as advisory evidence only; missing or unparsable LLM reviews fail-closed into `Unknown`.
|
|
58
|
+
- **CI & Build Modernization**:
|
|
59
|
+
- Aligned `.github/workflows/ci.yml` to automatically resolve `packageManager` from `package.json` (`pnpm@11.28.5`) via `pnpm/action-setup@v4`.
|
|
60
|
+
- Added `--ignore-scripts` to CI dependency installation to satisfy pnpm 11 build approval rules.
|
|
61
|
+
- **Removed Obsolete Baseline Checks**: Replaced redundant read-time SHA-256 CAS baseline checks in favor of DSH native `FS_STALE_VERSION`.
|
|
62
|
+
- **Clean Lifecycle Integration**: Public entry points export strictly necessary Cordis contracts; host services (`tools`, `commands`, `agentTeams`, `llm`, `userQuestions`) resolve dynamically at runtime with graceful degradation.
|
|
63
|
+
|
|
64
|
+
### Fixed
|
|
65
|
+
|
|
66
|
+
- **Sub-Agent Approval Route**: Addressed DSH sub-agent approval policy pinned to `never`; teammate out-of-scope and sensitive writes are denied directly and forwarded to Lead rather than triggering deadlocked prompts.
|
|
67
|
+
- **Safe Rollback**: Prevented rollbacks from clobbering newer external file modifications using pre-apply disk state verification (`ROLLBACK_CONFLICT`).
|
|
68
|
+
- **Binary-Safe Snapshots**: Preserved non-UTF-8 and binary assets via Base64 encoding rather than corrupted UTF-8 string conversions.
|
|
69
|
+
- **Fail-Closed Authority Kernel**: If the authority kernel or hash-chained log is corrupt, mutations are refused rather than falling back to self-declared scopes.
|
|
70
|
+
- **Markdown Header False Positive**: Fixed Git conflict parser to distinguish Markdown heading underlines (`=======`) from actual conflict blocks.
|
|
71
|
+
- **Deadlock Escalation Timeout**: Added defensive 10-minute timeout to human attention prompts to eliminate indefinite token burn.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 fengzhiyushui and dsh-inkstone-agent contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,310 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-inkstone-agent
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[English](README.md) | [简体中文](README.zh.md)
|
|
4
|
+
|
|
5
|
+
> [!WARNING]
|
|
6
|
+
> **Critical Warnings & Notices**:
|
|
7
|
+
> - **Mandatory Policy File**: Missing `.inkstone.policy.json` **blocks task completion** due to lack of objective evidence.
|
|
8
|
+
> - **Review-Ready Only**: Passing the gate only signals readiness for human review; **never auto-merges or deploys**.
|
|
9
|
+
> - **In-Memory Snapshots & Memory**: File snapshots and C4 immune memories live in process RAM and **reset upon host restart (not persisted)**; raw shell writes (e.g. `>`) bypass hooks.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Table of Contents
|
|
14
|
+
|
|
15
|
+
- [1. Overview](#1-overview)
|
|
16
|
+
- [2. Quick Installation & Host Integration](#2-quick-installation--host-integration)
|
|
17
|
+
- [3. Quick Start Guide](#3-quick-start-guide)
|
|
18
|
+
- [4. Project Verification Policy (.inkstone.policy.json) Configuration Guide](#4-project-verification-policy-inkstonepolicyjson-configuration-guide)
|
|
19
|
+
- [4.1 Purpose & Anti-Injection Rules](#41-purpose--anti-injection-rules)
|
|
20
|
+
- [4.2 Configuration Schema](#42-configuration-schema)
|
|
21
|
+
- [4.3 Security Allow-List Rules](#43-security-allow-list-rules)
|
|
22
|
+
- [4.4 Ready-to-Use Templates](#44-ready-to-use-templates)
|
|
23
|
+
- [5. Configuration Parameters](#5-configuration-parameters)
|
|
24
|
+
- [5.1 Master Switches](#51-master-switches)
|
|
25
|
+
- [5.2 Complete Parameters Table](#52-complete-parameters-table)
|
|
26
|
+
- [6. Slash Commands & Model Tools Reference](#6-slash-commands--model-tools-reference)
|
|
27
|
+
- [6.1 Human Slash Commands](#61-human-slash-commands)
|
|
28
|
+
- [6.2 Model Tools](#62-model-tools)
|
|
29
|
+
- [7. Detailed Tutorials & Workflows (Separate Docs)](#7-detailed-tutorials--workflows-separate-docs)
|
|
30
|
+
- [8. State Persistence & Threat Boundaries](#8-state-persistence--threat-boundaries)
|
|
31
|
+
- [9. Development & Testing](#9-development--testing)
|
|
32
|
+
- [10. Future Roadmap](#10-future-roadmap)
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## 1. Overview
|
|
37
|
+
|
|
38
|
+
`dsh-inkstone-agent` is an autonomous engineering host plugin for **DeepSeek Harness (DSH)**. Rather than simply stacking agent quantities, it focuses on deterministic governance: **which files may be touched**, **whether modifications can be rolled back**, and **when a task is genuinely complete**.
|
|
39
|
+
|
|
40
|
+
### Four Core Pillars
|
|
41
|
+
|
|
42
|
+
1. **L1 Mandate Engine & AST Semantic Impact**: Traces call graphs and verifies caller integrity when exported signatures change;
|
|
43
|
+
2. **L2 Hard Confinement & Transactional Snapshots**: Hard write boundaries (Sandbox $\cap$ Grant $\cap$ Task Scope), byte-exact before/after snapshots, atomic rollback, and secret redaction;
|
|
44
|
+
3. **L3 Zero-Trust Tribunal & Attention Firewall**: Intercepts task completion, enforces objective policy commands, and breaks deadlocks via human 3-choice attention dialogs;
|
|
45
|
+
4. **L4 C4 Self-Evolving Immune Memory**: Distills high-signal lessons from recoveries and rollbacks to inject historical risk cues before new tasks begin.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## 2. Quick Installation & Host Integration
|
|
50
|
+
|
|
51
|
+
### 2.1 Installation
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
# Method 1: npm registry (recommended)
|
|
55
|
+
pnpm add dsh-inkstone-agent
|
|
56
|
+
|
|
57
|
+
# Method 2: Direct GitHub installation (pre-built lib/ included in repo)
|
|
58
|
+
pnpm add github:fengzhiyushui/dsh-inkstone-agent
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### 2.2 Host Registration (cordis.patch.yml)
|
|
62
|
+
|
|
63
|
+
Declare the plugin in your DSH `cordis.patch.yml`:
|
|
64
|
+
|
|
65
|
+
```yaml
|
|
66
|
+
- insert:
|
|
67
|
+
- id: dsh-inkstone-agent
|
|
68
|
+
name: dsh-inkstone-agent
|
|
69
|
+
config:
|
|
70
|
+
confinementEnabled: true # Write boundaries, snapshots & atomic rollback
|
|
71
|
+
tribunalEnabled: true # Evidence-based completion gate
|
|
72
|
+
immuneMemoryEnabled: true # C4 immune memory distillation & injection
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Host services (`tools`, `commands`, `agentTeams`, etc.) are discovered dynamically at runtime with graceful degradation.
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## 3. Quick Start Guide
|
|
80
|
+
|
|
81
|
+
1. **Install and register the plugin** in `cordis.patch.yml`;
|
|
82
|
+
2. **Add a minimal policy file** `.inkstone.policy.json` to the workspace root (see Section 4);
|
|
83
|
+
3. **Autonomous coding with atomic safety nets**:
|
|
84
|
+
- Edits automatically create transactional snapshots;
|
|
85
|
+
- Use `/changes` to view recent transactions;
|
|
86
|
+
- Use `/rollback latest` to undo the last edit instantly;
|
|
87
|
+
- Teammate out-of-scope edits are blocked and redirected to `mandate_handback`.
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## 4. Project Verification Policy (.inkstone.policy.json) Configuration Guide
|
|
92
|
+
|
|
93
|
+
### 4.1 Purpose & Anti-Injection Rules
|
|
94
|
+
|
|
95
|
+
When `tribunalEnabled: true`, **`.inkstone.policy.json` must be present at the workspace root**:
|
|
96
|
+
- **Why Human-Authored**: Agents are physically blocked from modifying this file to prevent prompt injection or weakening verification rules;
|
|
97
|
+
- **Missing File Impact**: Without this file, the tribunal gate cannot establish a trusted verification baseline, resulting in `INKSTONE_EVIDENCE_UNKNOWN` which **blocks task completion**.
|
|
98
|
+
|
|
99
|
+
### 4.2 Configuration Schema
|
|
100
|
+
|
|
101
|
+
Located at `<workspaceRoot>/.inkstone.policy.json`:
|
|
102
|
+
|
|
103
|
+
```json
|
|
104
|
+
{
|
|
105
|
+
"version": 1,
|
|
106
|
+
"forbidProtectedChanges": false,
|
|
107
|
+
"commands": [
|
|
108
|
+
{
|
|
109
|
+
"id": "typecheck",
|
|
110
|
+
"run": "pnpm run typecheck",
|
|
111
|
+
"required": true,
|
|
112
|
+
"timeoutMs": 600000
|
|
113
|
+
}
|
|
114
|
+
]
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
| Field | Type | Required | Default | Description |
|
|
119
|
+
| :--- | :---: | :---: | :---: | :--- |
|
|
120
|
+
| `version` | `number` | **Yes** | `1` | Schema version, must be `1`. |
|
|
121
|
+
| `forbidProtectedChanges` | `boolean` | No | `false` | If protected files (tests, CI, lockfiles) are modified:<br/>• `false`: Pauses for human `/inkstone-approve`;<br/>• `true`: Fails immediately without human override option. |
|
|
122
|
+
| `commands` | `array` | **Yes** | - | Array of verification commands (max 12 commands, max 512 chars each). |
|
|
123
|
+
| `commands[].id` | `string` | **Yes** | - | Unique command identifier (e.g. `typecheck`, `test`, `build`). |
|
|
124
|
+
| `commands[].run` | `string` | **Yes** | - | Command line string (parsed as argument list directly, no shell). |
|
|
125
|
+
| `commands[].required` | `boolean` | No | `true` | When `true`, command must exit with code `0`. |
|
|
126
|
+
| `commands[].timeoutMs` | `number` | No | `600000` | Timeout in milliseconds (default 10 min, max 30 min / `1800000`). |
|
|
127
|
+
|
|
128
|
+
### 4.3 Security Allow-List Rules
|
|
129
|
+
|
|
130
|
+
Commands run directly as argv without passing through a shell:
|
|
131
|
+
1. **Allowed Executables**:
|
|
132
|
+
`pnpm`, `npm`, `yarn`, `bun`, `node`, `npx`, `tsc`, `vitest`, `jest`, `playwright`, `pytest`, `python`, `python3`, `cargo`, `go`, `make`, `mvn`, `gradle`, `dotnet`.
|
|
133
|
+
2. **Forbidden Patterns** (tripping any causes validation failure and blocks completion):
|
|
134
|
+
- ❌ Executable name with path separators (e.g. `./bin/test`);
|
|
135
|
+
- ❌ Shell syntax (`;`, `&`, `|`, `>`, `<`, `$`, backticks, parentheses, braces);
|
|
136
|
+
- ❌ Inline evaluation flags (`node -e`, `python -c`, etc.).
|
|
137
|
+
|
|
138
|
+
### 4.4 Ready-to-Use Templates
|
|
139
|
+
|
|
140
|
+
#### Template 1: Minimal Empty Policy (Syntax, Conflict & AST Checks Only)
|
|
141
|
+
```json
|
|
142
|
+
{
|
|
143
|
+
"version": 1,
|
|
144
|
+
"forbidProtectedChanges": false,
|
|
145
|
+
"commands": []
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
#### Template 2: TypeScript / Node.js Standard Policy
|
|
150
|
+
```json
|
|
151
|
+
{
|
|
152
|
+
"version": 1,
|
|
153
|
+
"forbidProtectedChanges": false,
|
|
154
|
+
"commands": [
|
|
155
|
+
{ "id": "typecheck", "run": "pnpm run typecheck", "required": true, "timeoutMs": 600000 },
|
|
156
|
+
{ "id": "test", "run": "pnpm test", "required": true, "timeoutMs": 900000 },
|
|
157
|
+
{ "id": "build", "run": "pnpm run build", "required": true, "timeoutMs": 900000 }
|
|
158
|
+
]
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
#### Template 3: Python Standard Policy
|
|
163
|
+
```json
|
|
164
|
+
{
|
|
165
|
+
"version": 1,
|
|
166
|
+
"forbidProtectedChanges": false,
|
|
167
|
+
"commands": [
|
|
168
|
+
{ "id": "lint", "run": "pytest --flake8", "required": true },
|
|
169
|
+
{ "id": "test", "run": "pytest tests/", "required": true, "timeoutMs": 600000 }
|
|
170
|
+
]
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
#### Template 4: Rust / Go Standard Policy
|
|
175
|
+
```json
|
|
176
|
+
{
|
|
177
|
+
"version": 1,
|
|
178
|
+
"forbidProtectedChanges": false,
|
|
179
|
+
"commands": [
|
|
180
|
+
{ "id": "check", "run": "cargo check", "required": true },
|
|
181
|
+
{ "id": "test", "run": "cargo test", "required": true, "timeoutMs": 900000 }
|
|
182
|
+
]
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## 5. Configuration Parameters
|
|
189
|
+
|
|
190
|
+
### 5.1 Master Switches
|
|
191
|
+
|
|
192
|
+
```yaml
|
|
193
|
+
confinementEnabled: true # Write boundaries, snapshots & rollback
|
|
194
|
+
tribunalEnabled: true # Objective completion gate (requires policy file)
|
|
195
|
+
immuneMemoryEnabled: true # C4 immune memory distillation & injection
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### 5.2 Complete Parameters Table
|
|
199
|
+
|
|
200
|
+
All parameters carry secure built-in defaults defined in [`src/config.ts`](src/config.ts):
|
|
201
|
+
|
|
202
|
+
| Parameter | Default | Type | Description |
|
|
203
|
+
| :--- | :---: | :---: | :--- |
|
|
204
|
+
| `confinementEnabled` | `true` | `boolean` | Master switch for write confinement & rollback. |
|
|
205
|
+
| `tribunalEnabled` | `true` | `boolean` | Master switch for completion gate and evidence. |
|
|
206
|
+
| `immuneMemoryEnabled` | `true` | `boolean` | Master switch for C4 immune memory. |
|
|
207
|
+
| `requireWriteScopeInTeam` | `true` | `boolean` | Requires teammates to hold task scopes before writing. |
|
|
208
|
+
| `sensitiveFilePolicy` | `'ask'` | `'ask' \| 'deny'` | Policy for sensitive files (.env, keys). |
|
|
209
|
+
| `outOfScopePolicy` | `'handback'` | `'handback' \| 'deny'` | Strategy for out-of-scope edits (`handback` creates request). |
|
|
210
|
+
| `maxSnapshotBytes` | `1048576` (1 MiB) | `number` | File snapshot limit before hash-only truncation guard. |
|
|
211
|
+
| `maxChangeRecords` | `50` | `number` | In-memory change records history ceiling per workspace. |
|
|
212
|
+
| `redactSecrets` | `true` | `boolean` | Auto-redaction of secrets in tool execution outputs. |
|
|
213
|
+
| `tribunalModelReviewEnabled`| `false` | `boolean` | Secondary read-only LLM reviewer pass (default `false`). |
|
|
214
|
+
| `maxTribunalRejections` | `2` | `number` | Rejection threshold before deadlock attention escalation. |
|
|
215
|
+
| `astImpactCheckEnabled` | `true` | `boolean` | AST broken-caller check on modified export signatures. |
|
|
216
|
+
| `maxImmuneExperiences` | `200` | `number` | Experience memory capacity per workspace. |
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
## 6. Slash Commands & Model Tools Reference
|
|
221
|
+
|
|
222
|
+
### 6.1 Human Slash Commands
|
|
223
|
+
|
|
224
|
+
> 💡 **Tip**: Intended for human developers in the DSH chat UI. Not callable by agents.
|
|
225
|
+
|
|
226
|
+
| Command | Syntax | Description |
|
|
227
|
+
| :--- | :--- | :--- |
|
|
228
|
+
| `/changes` | `/changes [limit]` | List recent transactional changes and change IDs. |
|
|
229
|
+
| `/rollback` | `/rollback [latest \| <changeId> \| <taskId> \| <agent>] [--force]` | Roll back changes. `--force` allows overwriting newer edits. |
|
|
230
|
+
| `/mandate` | `/mandate [add <paths...> \| clear \| view]` | Inspect or temporarily expand write grants. |
|
|
231
|
+
| `/inkstone-approve`| `/inkstone-approve [reason]` | Approve high-risk protected file changes on current hash. |
|
|
232
|
+
| `/immune` | `/immune [list \| clear]` | View or clear C4 immune memories. |
|
|
233
|
+
|
|
234
|
+
### 6.2 Model Tools
|
|
235
|
+
|
|
236
|
+
| Tool | Parameters | Description |
|
|
237
|
+
| :--- | :--- | :--- |
|
|
238
|
+
| `mandate_analyze` | `target_file`, `symbol_name?`, `hops?` | Analyze 1–2 hop upstream/downstream AST callers. |
|
|
239
|
+
| `mandate_handback` | `target_file`, `requested_change`, `reason`, `target_agent?` | Request owner agent to modify an out-of-scope file. |
|
|
240
|
+
| `tribunal_verify` | `task_id?` | Pre-flight completion evidence check. |
|
|
241
|
+
| `inkstone_rollback` | `target` | Autonomous rollback without `--force`. |
|
|
242
|
+
| `inkstone_worktree` | `action: 'create' \| 'status'` | Git worktree isolation with explicit degradation. |
|
|
243
|
+
| `inkstone_integrate`| `source_root`, `task_id?`, `target_root?` | Serial integration of net diffs (Lead-only). |
|
|
244
|
+
| `inkstone_challenge`| `action: 'open' \| 'report_finding' \| 'resolve_finding' \| 'close' \| 'list'` | Challenge task lifecycle and findings. |
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## 7. Detailed Tutorials & Workflows (Separate Docs)
|
|
249
|
+
|
|
250
|
+
For comprehensive, step-by-step practical guides, refer to our dedicated tutorial documents:
|
|
251
|
+
|
|
252
|
+
- 📖 [**详细使用教程与工作流实战(中文版)**](docs/TUTORIAL.zh.md)
|
|
253
|
+
- 📖 [**In-Depth Usage Tutorial & Workflow Guide (English)**](docs/TUTORIAL.md)
|
|
254
|
+
|
|
255
|
+
**Topics Covered**:
|
|
256
|
+
1. Multi-Agent Team Coordination, Write Confinement & Handback
|
|
257
|
+
2. Transactional Snapshots, Truncation Guards & Rollback Conflicts
|
|
258
|
+
3. Zero-Trust Tribunal Objective Evidence Chain & 3-State Verdicts
|
|
259
|
+
4. Deadlock Watchdog Fingerprinting & 10-Minute Timeout Attention Cards
|
|
260
|
+
5. On-Demand Challenge Tasks (ChallengeTask) & Finding Lifecycle
|
|
261
|
+
6. C4 Immune Memory Dynamic Scoring, Aging & Pre-Step Injection
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
## 8. State Persistence & Threat Boundaries
|
|
266
|
+
|
|
267
|
+
### 8.1 Persistence Matrix
|
|
268
|
+
|
|
269
|
+
| State Type | Location | Survives Restart? |
|
|
270
|
+
| :--- | :--- | :---: |
|
|
271
|
+
| **Grants & Decisions Log** | `<stateDir>/state/authority.jsonl` | **Yes** |
|
|
272
|
+
| **Challenges & Findings** | `<stateDir>/state/authority.jsonl` | **Yes** |
|
|
273
|
+
| **Worktree Registry** | `<stateDir>/state/worktrees.json` | **Yes** |
|
|
274
|
+
| **Policy Command Logs** | `<stateDir>/logs/` | **Yes** |
|
|
275
|
+
| **File Snapshots** | Host In-Memory (RAM) | **No** |
|
|
276
|
+
| **C4 Immune Memory** | Host In-Memory (RAM) | **No** |
|
|
277
|
+
|
|
278
|
+
### 8.2 Hash-Chained Audit Trail
|
|
279
|
+
`authority.jsonl` uses append-only logging where each record carries the SHA-256 hash of the previous line. External tampering trips hash validation and triggers **fail-closed shutdown**, denying further task updates and writes until repaired.
|
|
280
|
+
|
|
281
|
+
---
|
|
282
|
+
|
|
283
|
+
## 9. Development & Testing
|
|
284
|
+
|
|
285
|
+
```bash
|
|
286
|
+
# 1. Install dependencies (aligned with pnpm@11.28.5)
|
|
287
|
+
pnpm install
|
|
288
|
+
|
|
289
|
+
# 2. Type checking
|
|
290
|
+
pnpm run typecheck
|
|
291
|
+
|
|
292
|
+
# 3. Automated tests (6 suites, 12 test cases)
|
|
293
|
+
pnpm test
|
|
294
|
+
|
|
295
|
+
# 4. Production build (generates lib/index.js & lib/types/)
|
|
296
|
+
pnpm run build
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
---
|
|
300
|
+
|
|
301
|
+
## 10. Future Roadmap
|
|
302
|
+
|
|
303
|
+
- **Automatic Policy Initialization**: Future releases will explore automatically detecting project tech stacks and initializing baseline `.inkstone.policy.json` upon plugin enablement to reduce manual setup overhead;
|
|
304
|
+
- **Memory Plugin Integration**: Current C4 immune memory operates in-memory; we plan to integrate with a memory plugin in the future to achieve persistent, cross-session memory evolution and sharing.
|
|
305
|
+
|
|
306
|
+
---
|
|
307
|
+
|
|
308
|
+
## License
|
|
309
|
+
|
|
310
|
+
[MIT License](LICENSE) © 2026 fengzhiyushui
|