mirror of
https://github.com/profullstack/logicsrc.git
synced 2026-08-13 22:37:29 +00:00
Add AgentGit M1: agent-native git layer over a Forgejo backend
AgentGit is a thin, DID-gated source-collaboration layer over a backend forge (default Forgejo at git.profullstack.com, BBS-members-only) — not a new git host. M1 implements the contract and engines: - forge/adapter.ts: ForgeAdapter interface (only forge-specific surface) - forge/forgejo.ts: ForgejoAdapter over Forgejo/Gitea REST v1 (injectable fetch, typed errors), incl. ensureUser for member provisioning - access.ts: gateAccess DID membership gate (owner/role/visibility) - merge-policy.ts: evaluateMergePolicy pure engine (reviews, reputation floor, checks, escrow, merge method, agent-merge toggle) - service.ts: AgentGitService ties gate + policy to the adapter; refuses policy-failing merges; provisionMember hook for AgentBBS - schemas: logicsrc-repo + logicsrc-pull-request, registered in @logicsrc/validators with fixtures - docs/agentgit.md spec; plugin wired into root build (default/disabled) 27 vitest tests pass; full monorepo build green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
14fe9d608f
commit
bf046ae280
25 changed files with 1776 additions and 3 deletions
24
packages/schemas/fixtures/pull-request.yaml
Normal file
24
packages/schemas/fixtures/pull-request.yaml
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
type: logicsrc.pull_request
|
||||
version: "1.0"
|
||||
repo: agentgit-demo
|
||||
number: 7
|
||||
title: Add Forgejo backend adapter
|
||||
description: Implements the M1 ForgeAdapter against the Forgejo REST API.
|
||||
author_did: contributor.profullstack
|
||||
source_branch: feat/forgejo-adapter
|
||||
target_branch: main
|
||||
head_sha: abc1234
|
||||
task: task-42
|
||||
status: approved
|
||||
checks:
|
||||
- name: ci
|
||||
status: passing
|
||||
url: https://git.profullstack.com/owner/agentgit-demo/actions
|
||||
reviews:
|
||||
- reviewer_did: maintainer.profullstack
|
||||
decision: approve
|
||||
reputation: 25
|
||||
summary: Looks good, policy-gated merge verified.
|
||||
created_at: 2026-06-14T01:00:00Z
|
||||
created_at: 2026-06-14T00:30:00Z
|
||||
updated_at: 2026-06-14T01:05:00Z
|
||||
27
packages/schemas/fixtures/repo.yaml
Normal file
27
packages/schemas/fixtures/repo.yaml
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
type: logicsrc.repo
|
||||
version: "1.0"
|
||||
name: AgentGit Demo
|
||||
slug: agentgit-demo
|
||||
description: Reference AgentGit repository hosted on git.profullstack.com.
|
||||
owner_did: owner.profullstack
|
||||
board: /agentgit
|
||||
visibility: members_only
|
||||
default_branch: main
|
||||
backend:
|
||||
provider: forgejo
|
||||
url: https://git.profullstack.com
|
||||
external_id: owner/agentgit-demo
|
||||
members:
|
||||
- did: maintainer.profullstack
|
||||
role: maintainer
|
||||
- did: contributor.profullstack
|
||||
role: contributor
|
||||
merge_policy:
|
||||
min_reviews: 1
|
||||
require_passing_checks: true
|
||||
reviewer_reputation_min: 0
|
||||
escrow_required: false
|
||||
allow_agent_merge: true
|
||||
allowed_merge_methods:
|
||||
- squash
|
||||
created_at: 2026-06-14T00:00:00Z
|
||||
73
packages/schemas/schemas/logicsrc-pull-request.schema.json
Normal file
73
packages/schemas/schemas/logicsrc-pull-request.schema.json
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://schemas.logicsrc.com/logicsrc-pull-request.schema.json",
|
||||
"title": "LogicSRC Pull Request",
|
||||
"type": "object",
|
||||
"required": ["type", "version", "repo", "title", "author_did", "source_branch", "target_branch", "status"],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"type": { "const": "logicsrc.pull_request" },
|
||||
"version": { "type": "string", "pattern": "^\\d+\\.\\d+(\\.\\d+)?$" },
|
||||
"repo": { "type": "string", "pattern": "^[a-z0-9][a-z0-9/_-]*$" },
|
||||
"number": { "type": "integer", "minimum": 1 },
|
||||
"title": { "type": "string", "minLength": 1, "maxLength": 160 },
|
||||
"description": { "type": "string" },
|
||||
"author_did": { "$ref": "#/$defs/did" },
|
||||
"source_branch": { "type": "string", "minLength": 1 },
|
||||
"target_branch": { "type": "string", "minLength": 1 },
|
||||
"head_sha": { "type": "string", "pattern": "^[0-9a-f]{7,64}$" },
|
||||
"task": { "type": "string", "description": "Linked logicsrc.task id." },
|
||||
"status": {
|
||||
"type": "string",
|
||||
"enum": ["draft", "open", "approved", "changes_requested", "merged", "closed"]
|
||||
},
|
||||
"checks": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"required": ["name", "status"],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"name": { "type": "string", "minLength": 1 },
|
||||
"status": { "type": "string", "enum": ["pending", "passing", "failing"] },
|
||||
"url": { "type": "string", "format": "uri" }
|
||||
}
|
||||
}
|
||||
},
|
||||
"reviews": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"required": ["reviewer_did", "decision"],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"reviewer_did": { "$ref": "#/$defs/did" },
|
||||
"decision": { "type": "string", "enum": ["approve", "request_changes", "comment"] },
|
||||
"reputation": { "type": "number", "minimum": 0 },
|
||||
"summary": { "type": "string" },
|
||||
"created_at": { "type": "string", "format": "date-time" }
|
||||
}
|
||||
}
|
||||
},
|
||||
"merge": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"method": { "type": "string", "enum": ["merge", "squash", "rebase"] },
|
||||
"merged_by_did": { "$ref": "#/$defs/did" },
|
||||
"merge_sha": { "type": "string", "pattern": "^[0-9a-f]{7,64}$" },
|
||||
"policy_satisfied": { "type": "boolean" },
|
||||
"merged_at": { "type": "string", "format": "date-time" }
|
||||
}
|
||||
},
|
||||
"created_at": { "type": "string", "format": "date-time" },
|
||||
"updated_at": { "type": "string", "format": "date-time" },
|
||||
"logicsrc_version": { "type": "string" }
|
||||
},
|
||||
"$defs": {
|
||||
"did": {
|
||||
"type": "string",
|
||||
"pattern": "^[a-z0-9][a-z0-9._-]*\\.[a-z0-9][a-z0-9._-]*$"
|
||||
}
|
||||
}
|
||||
}
|
||||
73
packages/schemas/schemas/logicsrc-repo.schema.json
Normal file
73
packages/schemas/schemas/logicsrc-repo.schema.json
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://schemas.logicsrc.com/logicsrc-repo.schema.json",
|
||||
"title": "LogicSRC Repo",
|
||||
"type": "object",
|
||||
"required": ["type", "version", "name", "slug", "owner_did", "backend", "visibility"],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"type": { "const": "logicsrc.repo" },
|
||||
"version": { "type": "string", "pattern": "^\\d+\\.\\d+(\\.\\d+)?$" },
|
||||
"name": { "type": "string", "minLength": 1, "maxLength": 160 },
|
||||
"slug": { "type": "string", "pattern": "^[a-z0-9][a-z0-9/_-]*$" },
|
||||
"description": { "type": "string" },
|
||||
"owner_did": { "$ref": "#/$defs/did" },
|
||||
"board": { "type": "string", "pattern": "^/[a-z0-9][a-z0-9/_-]*$" },
|
||||
"visibility": {
|
||||
"type": "string",
|
||||
"enum": ["members_only", "private", "public"],
|
||||
"default": "members_only"
|
||||
},
|
||||
"default_branch": { "type": "string", "minLength": 1, "default": "main" },
|
||||
"backend": {
|
||||
"type": "object",
|
||||
"required": ["provider", "url"],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"provider": { "type": "string", "enum": ["forgejo", "github", "git"] },
|
||||
"url": { "type": "string", "format": "uri" },
|
||||
"external_id": { "type": "string" }
|
||||
}
|
||||
},
|
||||
"members": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"required": ["did", "role"],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"did": { "$ref": "#/$defs/did" },
|
||||
"role": {
|
||||
"type": "string",
|
||||
"enum": ["maintainer", "contributor", "reviewer", "reader"]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"merge_policy": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"min_reviews": { "type": "integer", "minimum": 0, "default": 1 },
|
||||
"require_passing_checks": { "type": "boolean", "default": true },
|
||||
"reviewer_reputation_min": { "type": "number", "minimum": 0, "default": 0 },
|
||||
"escrow_required": { "type": "boolean", "default": false },
|
||||
"allow_agent_merge": { "type": "boolean", "default": true },
|
||||
"allowed_merge_methods": {
|
||||
"type": "array",
|
||||
"items": { "type": "string", "enum": ["merge", "squash", "rebase"] },
|
||||
"uniqueItems": true,
|
||||
"default": ["squash"]
|
||||
}
|
||||
}
|
||||
},
|
||||
"created_at": { "type": "string", "format": "date-time" },
|
||||
"logicsrc_version": { "type": "string" }
|
||||
},
|
||||
"$defs": {
|
||||
"did": {
|
||||
"type": "string",
|
||||
"pattern": "^[a-z0-9][a-z0-9._-]*\\.[a-z0-9][a-z0-9._-]*$"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
"scripts": {
|
||||
"build": "tsc -p tsconfig.json",
|
||||
"test": "vitest run src",
|
||||
"validate:fixtures": "node dist/cli.js task ../schemas/fixtures/task.yaml && node dist/cli.js agent ../schemas/fixtures/agent.yaml && node dist/cli.js agentad-ad ../schemas/fixtures/agentad-ad.yaml && node dist/cli.js agentad-placement ../schemas/fixtures/agentad-placement.yaml"
|
||||
"validate:fixtures": "node dist/cli.js task ../schemas/fixtures/task.yaml && node dist/cli.js agent ../schemas/fixtures/agent.yaml && node dist/cli.js agentad-ad ../schemas/fixtures/agentad-ad.yaml && node dist/cli.js agentad-placement ../schemas/fixtures/agentad-placement.yaml && node dist/cli.js repo ../schemas/fixtures/repo.yaml && node dist/cli.js pull-request ../schemas/fixtures/pull-request.yaml"
|
||||
},
|
||||
"dependencies": {
|
||||
"ajv": "^8.17.1",
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import connectedAccountSchema from "../../schemas/schemas/logicsrc-connected-acc
|
|||
import emailMessageSchema from "../../schemas/schemas/logicsrc-email-message.schema.json" with { type: "json" };
|
||||
import eventSchema from "../../schemas/schemas/logicsrc-event.schema.json" with { type: "json" };
|
||||
import pluginSchema from "../../schemas/schemas/logicsrc-plugin.schema.json" with { type: "json" };
|
||||
import pullRequestSchema from "../../schemas/schemas/logicsrc-pull-request.schema.json" with { type: "json" };
|
||||
import repoSchema from "../../schemas/schemas/logicsrc-repo.schema.json" with { type: "json" };
|
||||
import runSchema from "../../schemas/schemas/logicsrc-run.schema.json" with { type: "json" };
|
||||
import socialPostSchema from "../../schemas/schemas/logicsrc-social-post.schema.json" with { type: "json" };
|
||||
import taskSchema from "../../schemas/schemas/logicsrc-task.schema.json" with { type: "json" };
|
||||
|
|
@ -26,6 +28,8 @@ export const schemas = {
|
|||
"email-message": emailMessageSchema,
|
||||
event: eventSchema,
|
||||
plugin: pluginSchema,
|
||||
"pull-request": pullRequestSchema,
|
||||
repo: repoSchema,
|
||||
run: runSchema,
|
||||
"social-post": socialPostSchema,
|
||||
task: taskSchema,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue