@zabaca/zbc 0.16.4 → 0.18.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/package.json +1 -1
- package/templates/apps/walgit/CONTEXT.md +31 -1
- package/templates/apps/walgit/README.md +48 -1
- package/templates/apps/walgit/e2e/README.md +44 -0
- package/templates/apps/walgit/e2e/load-report.ts +240 -0
- package/templates/apps/walgit/e2e/load.ts +449 -0
- package/templates/apps/walgit/package.json +2 -1
- package/templates/apps/walgit/shared/capabilities.ts +74 -0
- package/templates/apps/walgit/shared/container-env.ts +12 -0
- package/templates/apps/walgit/shared/events.ts +57 -8
- package/templates/apps/walgit/shared/landing.ts +169 -9
- package/templates/apps/walgit/shared/llms.ts +140 -6
- package/templates/apps/walgit/shared/operator.ts +86 -0
- package/templates/apps/walgit/shared/policy.ts +25 -0
- package/templates/apps/walgit/shared/protocol.ts +38 -0
- package/templates/apps/walgit/src/announce-main.ts +10 -2
- package/templates/apps/walgit/src/announce.ts +8 -1
- package/templates/apps/walgit/src/git-backend.ts +12 -0
- package/templates/apps/walgit/src/hook-main.ts +112 -4
- package/templates/apps/walgit/src/http.ts +202 -1
- package/templates/apps/walgit/src/instructions.ts +17 -1
- package/templates/apps/walgit/src/proposals.ts +360 -0
- package/templates/apps/walgit/src/push.ts +21 -1
- package/templates/apps/walgit/src/rate-limit.ts +264 -0
- package/templates/apps/walgit/src/server.ts +36 -0
- package/templates/apps/walgit/src/signers.ts +72 -0
- package/templates/apps/walgit/worker/index.ts +29 -2
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
import { authorizedBy } from './credentials'
|
|
26
|
-
import { REF_NAME, REPO_ID, ZERO_OID } from './protocol'
|
|
26
|
+
import { PROPOSAL_ID, REF_NAME, REPO_ID, ZERO_OID } from './protocol'
|
|
27
27
|
|
|
28
28
|
/** One repository, and optionally the refs within it that matter. */
|
|
29
29
|
export interface WatchEntry {
|
|
@@ -37,6 +37,22 @@ export interface RefEvent {
|
|
|
37
37
|
repo: string
|
|
38
38
|
ref: string
|
|
39
39
|
sha: string | null
|
|
40
|
+
/**
|
|
41
|
+
* The Proposals this move MERGED: their ids, when this ref is a branch whose
|
|
42
|
+
* new tip a Proposal's tip became an ancestor of under this push
|
|
43
|
+
* (docs/adr/0018).
|
|
44
|
+
*
|
|
45
|
+
* ABSENT when it merged none, and never an empty array: a subscriber asking
|
|
46
|
+
* `merged?.length` should not have to tell "nothing landed" from "this
|
|
47
|
+
* deployment does not do Proposals", because in both cases nothing landed.
|
|
48
|
+
*
|
|
49
|
+
* Still latest-state, and not a log (docs/adr/0009). It is a property of the
|
|
50
|
+
* move — what became true when the ref got here — which a handshake
|
|
51
|
+
* therefore cannot carry: nothing moved, so nothing merged. A subscriber that
|
|
52
|
+
* was disconnected reads what is open from `GET /<name>.git/proposals`, which
|
|
53
|
+
* recomputes it from ancestry and is the same answer.
|
|
54
|
+
*/
|
|
55
|
+
merged?: string[]
|
|
40
56
|
}
|
|
41
57
|
|
|
42
58
|
/** The answer to a `watch`: current state, before any event can fire. */
|
|
@@ -226,10 +242,11 @@ export function parseAnnounce(body: unknown): Parsed<Announcement> {
|
|
|
226
242
|
for (const item of events) {
|
|
227
243
|
if (typeof item !== 'object' || item === null)
|
|
228
244
|
return { ok: false, error: 'event is not an object' }
|
|
229
|
-
const { repo, ref, sha } = item as {
|
|
245
|
+
const { repo, ref, sha, merged } = item as {
|
|
230
246
|
repo?: unknown
|
|
231
247
|
ref?: unknown
|
|
232
248
|
sha?: unknown
|
|
249
|
+
merged?: unknown
|
|
233
250
|
}
|
|
234
251
|
if (typeof repo !== 'string' || !REPO_ID.test(repo)) {
|
|
235
252
|
return {
|
|
@@ -246,7 +263,28 @@ export function parseAnnounce(body: unknown): Parsed<Announcement> {
|
|
|
246
263
|
if (sha !== null && (typeof sha !== 'string' || !/^[0-9a-f]{40,64}$/.test(sha))) {
|
|
247
264
|
return { ok: false, error: `invalid sha for ${ref}` }
|
|
248
265
|
}
|
|
249
|
-
|
|
266
|
+
// The Proposal ids this move merged, judged by the same grammar the ref
|
|
267
|
+
// they came from is: the Fan-out hands these to subscribers untouched, so
|
|
268
|
+
// an id this door accepts is an id every watcher is told about.
|
|
269
|
+
if (merged !== undefined) {
|
|
270
|
+
if (!Array.isArray(merged)) return { ok: false, error: `"merged" for ${ref} is not an array` }
|
|
271
|
+
for (const id of merged) {
|
|
272
|
+
if (typeof id !== 'string' || !PROPOSAL_ID.test(id)) {
|
|
273
|
+
return {
|
|
274
|
+
ok: false,
|
|
275
|
+
error: `invalid Proposal id for ${ref}: ${JSON.stringify(id ?? null)}`,
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
parsed.push({
|
|
281
|
+
repo,
|
|
282
|
+
ref,
|
|
283
|
+
sha,
|
|
284
|
+
// Empty stays absent, as it is on the way out: one spelling of "nothing
|
|
285
|
+
// merged" on the wire, whichever end wrote it.
|
|
286
|
+
...(Array.isArray(merged) && merged.length > 0 ? { merged: [...(merged as string[])] } : {}),
|
|
287
|
+
})
|
|
250
288
|
}
|
|
251
289
|
return { ok: true, value: { events: parsed, readersChanged: [...(changed as string[])] } }
|
|
252
290
|
}
|
|
@@ -317,14 +355,25 @@ export function eventsFromChanges(
|
|
|
317
355
|
// straight from the push path, and a parameter narrower than what they hold
|
|
318
356
|
// would make every call site build a second object to drop one field.
|
|
319
357
|
changes: readonly { ref: string; oldOid?: string; newOid: string }[],
|
|
358
|
+
/**
|
|
359
|
+
* What each moved ref merged, by ref name (`mergedProposals` in
|
|
360
|
+
* `src/proposals.ts`). Handed in rather than computed here because it is an
|
|
361
|
+
* ancestry walk against the Cache, and this file is the pure wire — and
|
|
362
|
+
* empty, always, on a deployment not taking Proposals.
|
|
363
|
+
*/
|
|
364
|
+
merged: Readonly<Record<string, string[]>> = {},
|
|
320
365
|
): RefEvent[] {
|
|
321
366
|
return changes
|
|
322
367
|
.filter((change) => REF_NAME.test(change.ref))
|
|
323
|
-
.map((change) =>
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
368
|
+
.map((change) => {
|
|
369
|
+
const ids = merged[change.ref]
|
|
370
|
+
return {
|
|
371
|
+
repo,
|
|
372
|
+
ref: change.ref,
|
|
373
|
+
sha: change.newOid === ZERO_OID ? null : change.newOid,
|
|
374
|
+
...(ids && ids.length > 0 ? { merged: [...ids] } : {}),
|
|
375
|
+
}
|
|
376
|
+
})
|
|
328
377
|
}
|
|
329
378
|
|
|
330
379
|
/** One message on the wire. Serialized in one place so its shape is one thing. */
|
|
@@ -50,7 +50,8 @@
|
|
|
50
50
|
*/
|
|
51
51
|
|
|
52
52
|
import type { Capabilities } from './capabilities'
|
|
53
|
-
import {
|
|
53
|
+
import { contactHref, type Operator } from './operator'
|
|
54
|
+
import { describeBytes, describeWindow } from './policy'
|
|
54
55
|
import { EVENTS_PATH, SIGNERS_REF } from './protocol'
|
|
55
56
|
import { CONTENT_SIGNAL } from './robots'
|
|
56
57
|
|
|
@@ -107,6 +108,34 @@ function thirdClaim(caps: Capabilities): string {
|
|
|
107
108
|
return ''
|
|
108
109
|
}
|
|
109
110
|
|
|
111
|
+
/**
|
|
112
|
+
* What one client may spend in a window (`src/rate-limit.ts`).
|
|
113
|
+
*
|
|
114
|
+
* Its own term rather than a share of the slot above, because it answers a
|
|
115
|
+
* different question: the size caps say how big a thing may be, this says how
|
|
116
|
+
* much of the host is yours. A visitor about to point an agent loop at this
|
|
117
|
+
* page should read it here rather than in the refusal — which is the same
|
|
118
|
+
* reason every other limit is on this page at all.
|
|
119
|
+
*
|
|
120
|
+
* Absent when the deployment bounds nothing per source, which is the default.
|
|
121
|
+
*/
|
|
122
|
+
function sourceLimitClaim(caps: Capabilities): string {
|
|
123
|
+
if (!caps.sourceLimited) return ''
|
|
124
|
+
const window = describeWindow(caps.rateWindowSeconds)
|
|
125
|
+
const parts: string[] = []
|
|
126
|
+
if (caps.maxNewReposPerSource !== null) {
|
|
127
|
+
parts.push(`${caps.maxNewReposPerSource} new repositories`)
|
|
128
|
+
}
|
|
129
|
+
if (caps.maxPushesPerSource !== null) parts.push(`${caps.maxPushesPerSource} pushes`)
|
|
130
|
+
if (caps.maxPushBytesPerSource !== null) {
|
|
131
|
+
parts.push(describeBytes(caps.maxPushBytesPerSource))
|
|
132
|
+
}
|
|
133
|
+
return claim(
|
|
134
|
+
'Shared',
|
|
135
|
+
`<b>${parts.join(', ')} per client per ${window}.</b> One host serves everybody here, so no single client may take all of it.`,
|
|
136
|
+
)
|
|
137
|
+
}
|
|
138
|
+
|
|
110
139
|
/** The permanence sentence, which turns on the same variable as the claim. */
|
|
111
140
|
function permanence(caps: Capabilities): string {
|
|
112
141
|
return caps.retentionHours === null
|
|
@@ -284,6 +313,31 @@ function publicClaim(caps: Capabilities): string {
|
|
|
284
313
|
* learns "a repository is Private if it holds a `readers` file" knows the
|
|
285
314
|
* entire model. How to write one is `/llms.txt`, and the refusal itself.
|
|
286
315
|
*/
|
|
316
|
+
/**
|
|
317
|
+
* Proposals, as a rule of the host rather than a row in what is missing
|
|
318
|
+
* (docs/adr/0018).
|
|
319
|
+
*
|
|
320
|
+
* The `Pull requests` roadmap row has said *under design* since the page was
|
|
321
|
+
* written, and this is where it is spent — the same move Ownership and Private
|
|
322
|
+
* made, and for the same reason: a page carrying one capability twice, once as
|
|
323
|
+
* a fact and once as an achievement, is a page arguing with itself.
|
|
324
|
+
*
|
|
325
|
+
* Read from `proposals`, which is the only reading that can be right here: a
|
|
326
|
+
* Proposal is a SIGNED push to a name that HOLDS a Signer List, so the flag
|
|
327
|
+
* alone describes a handoff no push on that deployment could make.
|
|
328
|
+
*
|
|
329
|
+
* It names the ref, because the ref is the whole mechanism: there is no button,
|
|
330
|
+
* no record and no third list — the pusher picks the id, the target is in the
|
|
331
|
+
* name, and *merged* is the target's history containing it.
|
|
332
|
+
*/
|
|
333
|
+
function proposalsClaim(caps: Capabilities): string {
|
|
334
|
+
if (!caps.proposals) return ''
|
|
335
|
+
return claim(
|
|
336
|
+
'Proposals',
|
|
337
|
+
'<b>A claimed name takes a change from anyone who may read it.</b> Push to <code>refs/walgit/proposals/<branch>/<your-id></code> and it is held, signed and append-only, without being a Signer. Nobody accepts it but a Signer merging it themselves: it is <em>merged</em> when the branch\u2019s history contains it, and there is nothing else to be.',
|
|
338
|
+
)
|
|
339
|
+
}
|
|
340
|
+
|
|
287
341
|
function privateClaim(caps: Capabilities): string {
|
|
288
342
|
if (!caps.namesCanBePrivate) return ''
|
|
289
343
|
return claim(
|
|
@@ -451,7 +505,9 @@ function claims(caps: Capabilities): string {
|
|
|
451
505
|
appendOnlyClaim(caps),
|
|
452
506
|
publicClaim(caps),
|
|
453
507
|
privateClaim(caps),
|
|
508
|
+
proposalsClaim(caps),
|
|
454
509
|
thirdClaim(caps),
|
|
510
|
+
sourceLimitClaim(caps),
|
|
455
511
|
signingClaim(caps),
|
|
456
512
|
// Unconditional, unlike every term above it: nothing in `/robots.txt` is
|
|
457
513
|
// read from a flag. It is the one claim on this page addressed to the
|
|
@@ -565,9 +621,19 @@ function roadmapOwnership(caps: Capabilities): string {
|
|
|
565
621
|
* the reason one of them is cheap rather than part of it.
|
|
566
622
|
*/
|
|
567
623
|
function roadmapPulls(caps: Capabilities): string {
|
|
568
|
-
|
|
624
|
+
// The row LEAVES when the deployment takes Proposals, exactly as Ownership
|
|
625
|
+
// and Private leave: `proposalsClaim` above states the rule, and a roadmap
|
|
626
|
+
// row calling it under design underneath would be the page describing one
|
|
627
|
+
// capability in two contradictory places.
|
|
628
|
+
if (caps.proposals) return ''
|
|
629
|
+
const missing = caps.appendOnly
|
|
569
630
|
? 'Append-only already makes a proposal safe to push. What is missing is a way to say a branch is one, and a way to say it landed — not a review UI.'
|
|
570
631
|
: 'A branch is already the whole of a proposal. What is missing is a way to say that is what it is, and a way to say it landed — not a review UI.'
|
|
632
|
+
return ` <li>
|
|
633
|
+
<span class="when">Under design</span>
|
|
634
|
+
<h3>Pull requests</h3>
|
|
635
|
+
<p>${missing}</p>
|
|
636
|
+
</li>`
|
|
571
637
|
}
|
|
572
638
|
|
|
573
639
|
/**
|
|
@@ -581,6 +647,81 @@ function wireScript(): string {
|
|
|
581
647
|
return `${WIRE_CLIENT}`
|
|
582
648
|
}
|
|
583
649
|
|
|
650
|
+
/**
|
|
651
|
+
* Everything on this page is a constant of the template or a number read from
|
|
652
|
+
* the environment — except the two values below, which are free text somebody
|
|
653
|
+
* put in a deployment variable and which land in markup. So they are escaped
|
|
654
|
+
* here, once, at the only place they enter the document.
|
|
655
|
+
*/
|
|
656
|
+
function escapeHtml(raw: string): string {
|
|
657
|
+
return raw
|
|
658
|
+
.replaceAll('&', '&')
|
|
659
|
+
.replaceAll('<', '<')
|
|
660
|
+
.replaceAll('>', '>')
|
|
661
|
+
.replaceAll('"', '"')
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
/**
|
|
665
|
+
* Who runs this, and what happens to what you push.
|
|
666
|
+
*
|
|
667
|
+
* The one block on the page addressed to somebody who is not about to push:
|
|
668
|
+
* an aggregator asks who is answerable in the first ten minutes, and the page
|
|
669
|
+
* that could not answer sent them looking for a WHOIS record.
|
|
670
|
+
*
|
|
671
|
+
* The expiry promise stands here as well as in `The rules.` on purpose, and it
|
|
672
|
+
* is not the page saying one thing twice — the terms tell a visitor what the
|
|
673
|
+
* host will do with their push, and this tells somebody else what it already
|
|
674
|
+
* did with a stranger's. On a deployment that collects, "it expires in 24
|
|
675
|
+
* hours" is most of the answer to a takedown, so the two facts are read
|
|
676
|
+
* together or not at all. It is rendered from `retentionHours` like every
|
|
677
|
+
* other statement of the window, so it cannot outlive the config either.
|
|
678
|
+
*
|
|
679
|
+
* Absent whole where nothing is configured, for the reason `operatorFrom`
|
|
680
|
+
* returns `null` there: a page that printed a heading with nobody under it
|
|
681
|
+
* would be worse than one that never claimed to have an operator.
|
|
682
|
+
*/
|
|
683
|
+
function operatorSection(caps: Capabilities, operator: Operator | null): string {
|
|
684
|
+
if (operator === null) return ''
|
|
685
|
+
|
|
686
|
+
const rows: string[] = []
|
|
687
|
+
if (operator.name !== null) {
|
|
688
|
+
rows.push(claim('Operator', `<b>${escapeHtml(operator.name)}</b> runs this deployment.`))
|
|
689
|
+
}
|
|
690
|
+
if (operator.contact !== null) {
|
|
691
|
+
const text = escapeHtml(operator.contact)
|
|
692
|
+
const href = contactHref(operator.contact)
|
|
693
|
+
rows.push(
|
|
694
|
+
claim(
|
|
695
|
+
'Contact',
|
|
696
|
+
`<b>${href === null ? text : `<a href="${escapeHtml(href)}">${text}</a>`}</b> — takedowns, abuse and anything else about this host.`,
|
|
697
|
+
),
|
|
698
|
+
)
|
|
699
|
+
}
|
|
700
|
+
if (caps.retentionHours !== null) {
|
|
701
|
+
const window = describeHours(caps.retentionHours)
|
|
702
|
+
rows.push(
|
|
703
|
+
claim(
|
|
704
|
+
'Expiry',
|
|
705
|
+
`<b>A repository is collected ${window} after its last push</b>, whether or not anybody asks. Nothing here is archived.`,
|
|
706
|
+
),
|
|
707
|
+
)
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
// `operatorFrom` cannot return an `Operator` with neither half, so this is
|
|
711
|
+
// unreachable from the Worker — but a heading with nothing under it is the
|
|
712
|
+
// one output this block must never produce, and the guard costs a line.
|
|
713
|
+
if (rows.length === 0) return ''
|
|
714
|
+
|
|
715
|
+
return `
|
|
716
|
+
<section>
|
|
717
|
+
<h2>Who runs this.</h2>
|
|
718
|
+
<ul class="claims">
|
|
719
|
+
${rows.join('\n')}
|
|
720
|
+
</ul>
|
|
721
|
+
</section>
|
|
722
|
+
`
|
|
723
|
+
}
|
|
724
|
+
|
|
584
725
|
/**
|
|
585
726
|
* Every substitution passes a FUNCTION, never the string itself.
|
|
586
727
|
*
|
|
@@ -594,7 +735,18 @@ function wireScript(): string {
|
|
|
594
735
|
* runs. A function replacer is not interpreted at all, so the question stops
|
|
595
736
|
* being asked.
|
|
596
737
|
*/
|
|
597
|
-
export function renderLanding(
|
|
738
|
+
export function renderLanding(
|
|
739
|
+
host: string,
|
|
740
|
+
caps: Capabilities,
|
|
741
|
+
/**
|
|
742
|
+
* Who runs this deployment (`shared/operator.ts`), beside the capabilities
|
|
743
|
+
* rather than folded into them: nothing branches on it and the push path
|
|
744
|
+
* never sees it. Optional and `null` by default — a deployment that names
|
|
745
|
+
* nobody renders the page it renders today, which is also what every test
|
|
746
|
+
* fixture that is not about the operator wants to say.
|
|
747
|
+
*/
|
|
748
|
+
operator: Operator | null = null,
|
|
749
|
+
): string {
|
|
598
750
|
return PAGE.replaceAll('{{HOST}}', () => host)
|
|
599
751
|
.replace('{{META_DESCRIPTION}}', () => metaDescription(caps))
|
|
600
752
|
.replace('{{HERO_UNDER}}', () => heroUnder(caps))
|
|
@@ -605,6 +757,7 @@ export function renderLanding(host: string, caps: Capabilities): string {
|
|
|
605
757
|
.replace('{{OWNERSHIP}}', () => ownershipSection(host, caps))
|
|
606
758
|
.replace('{{WIRE_SCRIPT}}', () => (caps.events ? wireScript() : ''))
|
|
607
759
|
.replace('{{PERMANENCE}}', () => permanence(caps))
|
|
760
|
+
.replace('{{OPERATOR}}', () => operatorSection(caps, operator))
|
|
608
761
|
}
|
|
609
762
|
|
|
610
763
|
const WIRE_CLIENT = `
|
|
@@ -758,6 +911,14 @@ const PAGE = `<!doctype html>
|
|
|
758
911
|
margin: 0 0 2.75rem;
|
|
759
912
|
}
|
|
760
913
|
.lede em { font-style: normal; color: var(--copper); }
|
|
914
|
+
/* The second half of the pitch — what the service is FOR, as opposed to what
|
|
915
|
+
it does — set a step down so the two read as one thought rather than as
|
|
916
|
+
two competing opening lines. */
|
|
917
|
+
.lede-2 {
|
|
918
|
+
font-size: clamp(1.02rem, 2.3vw, 1.2rem);
|
|
919
|
+
color: var(--muted);
|
|
920
|
+
max-width: 44ch;
|
|
921
|
+
}
|
|
761
922
|
|
|
762
923
|
/* ── the command, which is the CTA ────────────────────── */
|
|
763
924
|
|
|
@@ -1138,12 +1299,14 @@ const PAGE = `<!doctype html>
|
|
|
1138
1299
|
<div class="wrap">
|
|
1139
1300
|
|
|
1140
1301
|
<main id="start">
|
|
1141
|
-
<span class="badge">
|
|
1302
|
+
<span class="badge">agentgit — open source, run your own</span>
|
|
1142
1303
|
|
|
1143
1304
|
<h1>Git for AI agents<span class="dot">.</span></h1>
|
|
1144
1305
|
|
|
1145
1306
|
<p class="lede">Your agent writes code all day and has nowhere of its own to put it. <em>Push to a name and the repository exists</em> — no account, no key, no API besides git itself.</p>
|
|
1146
1307
|
|
|
1308
|
+
<p class="lede lede-2">Scratch repositories, and the handoff between two agents: <em>handing work to another agent is the URL</em>, and there is nothing else to send.</p>
|
|
1309
|
+
|
|
1147
1310
|
<div class="cta">
|
|
1148
1311
|
<label class="repo-field" for="repo">
|
|
1149
1312
|
<span>Name it</span>
|
|
@@ -1174,11 +1337,7 @@ const PAGE = `<!doctype html>
|
|
|
1174
1337
|
<p>What is missing, in the order it unblocks itself. Nothing here is a date, and each one is written down before it is built.</p>
|
|
1175
1338
|
<ul class="road">
|
|
1176
1339
|
{{ROADMAP_OWNERSHIP}}
|
|
1177
|
-
|
|
1178
|
-
<span class="when">Under design</span>
|
|
1179
|
-
<h3>Pull requests</h3>
|
|
1180
|
-
<p>{{ROADMAP_PULLS}}</p>
|
|
1181
|
-
</li>
|
|
1340
|
+
{{ROADMAP_PULLS}}
|
|
1182
1341
|
<li>
|
|
1183
1342
|
<span class="when">Half built</span>
|
|
1184
1343
|
<h3>CI</h3>
|
|
@@ -1187,6 +1346,7 @@ const PAGE = `<!doctype html>
|
|
|
1187
1346
|
</ul>
|
|
1188
1347
|
<p class="caveat">{{PERMANENCE}} Not a place for anything you cannot lose.</p>
|
|
1189
1348
|
</section>
|
|
1349
|
+
{{OPERATOR}}
|
|
1190
1350
|
</main>
|
|
1191
1351
|
|
|
1192
1352
|
<footer>
|
|
@@ -22,8 +22,9 @@
|
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
import type { Capabilities } from './capabilities'
|
|
25
|
+
import type { Operator } from './operator'
|
|
25
26
|
import { MAX_REFS_PER_ENTRY, MAX_WATCH_ENTRIES } from './events'
|
|
26
|
-
import { describeBytes } from './policy'
|
|
27
|
+
import { describeBytes, describeWindow } from './policy'
|
|
27
28
|
import { CONTENT_SIGNAL } from './robots'
|
|
28
29
|
import {
|
|
29
30
|
CHALLENGE_PATH,
|
|
@@ -41,7 +42,17 @@ export function wantsLlms(method: string, pathname: string): boolean {
|
|
|
41
42
|
|
|
42
43
|
const hours = (n: number) => (n === 1 ? '1 hour' : `${n} hours`)
|
|
43
44
|
|
|
44
|
-
export function renderLlms(
|
|
45
|
+
export function renderLlms(
|
|
46
|
+
host: string,
|
|
47
|
+
caps: Capabilities,
|
|
48
|
+
/**
|
|
49
|
+
* Who runs this deployment (`shared/operator.ts`), passed beside the
|
|
50
|
+
* capabilities for the reason the host is: nothing here branches on it and
|
|
51
|
+
* the push path never sees it. `null` — nobody named — renders the document
|
|
52
|
+
* this host rendered before there was anywhere to name one.
|
|
53
|
+
*/
|
|
54
|
+
operator: Operator | null = null,
|
|
55
|
+
): string {
|
|
45
56
|
const ws = `wss://${host}${EVENTS_PATH}`
|
|
46
57
|
|
|
47
58
|
const limits: string[] = []
|
|
@@ -106,6 +117,33 @@ export function renderLlms(host: string, caps: Capabilities): string {
|
|
|
106
117
|
if (caps.maxRepoBytes !== null) {
|
|
107
118
|
limits.push(`- **One repository may not exceed ${describeBytes(caps.maxRepoBytes)}** in total.`)
|
|
108
119
|
}
|
|
120
|
+
// What one client may spend, as opposed to how big one thing may be
|
|
121
|
+
// (`src/rate-limit.ts`). Stated here because the reader of this document is
|
|
122
|
+
// exactly the client the limit is about: an agent loop reads it once and then
|
|
123
|
+
// pushes in a pattern it has already decided on, and a limit it learns from a
|
|
124
|
+
// refusal is one it learns halfway through that pattern. Each half is stated
|
|
125
|
+
// only where it is enforced, like every bullet above.
|
|
126
|
+
if (caps.sourceLimited) {
|
|
127
|
+
const window = describeWindow(caps.rateWindowSeconds)
|
|
128
|
+
if (caps.maxNewReposPerSource !== null) {
|
|
129
|
+
limits.push(
|
|
130
|
+
`- **You may create ${caps.maxNewReposPerSource} new repositories per client per ${window}.** Pushing to a name you already created does not count against it.`,
|
|
131
|
+
)
|
|
132
|
+
}
|
|
133
|
+
if (caps.maxPushesPerSource !== null) {
|
|
134
|
+
limits.push(
|
|
135
|
+
`- **You may make ${caps.maxPushesPerSource} pushes per client per ${window}.** Commit locally and push once rather than pushing every commit.`,
|
|
136
|
+
)
|
|
137
|
+
}
|
|
138
|
+
if (caps.maxPushBytesPerSource !== null) {
|
|
139
|
+
limits.push(
|
|
140
|
+
`- **You may push ${describeBytes(caps.maxPushBytesPerSource)} per client per ${window}.**`,
|
|
141
|
+
)
|
|
142
|
+
}
|
|
143
|
+
limits.push(
|
|
144
|
+
`- Each of those is refused in \`pre-receive\`, by a message naming the limit — not a transport failure. Waiting out the ${window} is the remedy; retrying immediately is not.`,
|
|
145
|
+
)
|
|
146
|
+
}
|
|
109
147
|
|
|
110
148
|
/**
|
|
111
149
|
* The answer to the question the bullet above raises and does not settle: a
|
|
@@ -504,6 +542,101 @@ stream reading on the strength of the old list is closed when the push lands.
|
|
|
504
542
|
`
|
|
505
543
|
: ''
|
|
506
544
|
|
|
545
|
+
/**
|
|
546
|
+
* Proposals, taught where an agent that has work for a name it may not push
|
|
547
|
+
* to goes looking (docs/adr/0018).
|
|
548
|
+
*
|
|
549
|
+
* Placed after ownership and privacy because it depends on both in the strong
|
|
550
|
+
* sense: a Proposal is the one push a CLAIMED name takes from someone not on
|
|
551
|
+
* its Signer List, and who may propose is exactly who may read — which is
|
|
552
|
+
* everyone on a world-readable name and the Reader List on a Private one.
|
|
553
|
+
* `proposals` encodes that dependency, which is why it is the only flag read
|
|
554
|
+
* here.
|
|
555
|
+
*
|
|
556
|
+
* Every spelling is one the push path actually enforces — the namespace, the
|
|
557
|
+
* target in the ref name, the fast-forward that updates one — so an agent
|
|
558
|
+
* that reads this and an agent that reads the refusal are not being told
|
|
559
|
+
* about two different mechanisms.
|
|
560
|
+
*/
|
|
561
|
+
const proposing = caps.proposals
|
|
562
|
+
? `
|
|
563
|
+
## Propose a change
|
|
564
|
+
|
|
565
|
+
A name that holds a Signer List takes one push from someone it does not name: a
|
|
566
|
+
**Proposal**. It is a ref and its signature, and nothing else.
|
|
567
|
+
|
|
568
|
+
\`\`\`sh
|
|
569
|
+
git push --signed=yes https://${host}/$NAME.git HEAD:refs/walgit/proposals/main/fix-auth
|
|
570
|
+
\`\`\`
|
|
571
|
+
|
|
572
|
+
\`main\` is the branch you want it in and must already exist there; \`fix-auth\` is
|
|
573
|
+
your own word for the change. The host assigns nothing and stores nothing else:
|
|
574
|
+
there is no number to wait for and no record beyond the ref.
|
|
575
|
+
|
|
576
|
+
- **Whoever may read may propose.** On a world-readable name that is anyone
|
|
577
|
+
whose push is signed; on a Private one it is the Reader List and the Signers.
|
|
578
|
+
There is no third list to be added to.
|
|
579
|
+
- **Update it with a fast-forward** to the same ref. A taken id belongs to
|
|
580
|
+
whoever pushed it first — a second pusher is refused as a non-fast-forward,
|
|
581
|
+
and picks another id.
|
|
582
|
+
- **Merged is ancestry.** It is merged when the branch's history contains its
|
|
583
|
+
commit, computed when somebody asks and never recorded. A squash or a rebase
|
|
584
|
+
of your commits is a different commit, so it never marks one merged.
|
|
585
|
+
- **Nobody accepts it but a Signer.** There is no merge button and no endpoint:
|
|
586
|
+
a Signer fetches it, merges or fast-forwards it in their own tree, and pushes.
|
|
587
|
+
Conflicts are resolved where git resolves them.
|
|
588
|
+
|
|
589
|
+
Read what is open with \`curl https://${host}/$NAME.git/proposals\` — a JSON array
|
|
590
|
+
of \`{ id, target, tip, pusher, merged }\`, behind the same credential a clone of
|
|
591
|
+
that name needs. \`git ls-remote https://${host}/$NAME.git 'refs/walgit/proposals/*'\`
|
|
592
|
+
lists the same refs without the verdict: the target is in the ref name, so
|
|
593
|
+
nothing has to be fetched either way.
|
|
594
|
+
|
|
595
|
+
${
|
|
596
|
+
caps.events
|
|
597
|
+
? `If you are watching the branch (below), you do not have to ask twice: the event
|
|
598
|
+
for a branch that moved carries \`merged\` — the ids of the Proposals that move
|
|
599
|
+
landed — and leaves the field out when it landed none.
|
|
600
|
+
|
|
601
|
+
`
|
|
602
|
+
: ''
|
|
603
|
+
}A Proposal is a push like any other: it is signed, it is append-only, it counts
|
|
604
|
+
against the name's size caps, and it cannot be deleted or withdrawn. A target
|
|
605
|
+
that does not exist, a target that is not a branch, and a tip that is not a
|
|
606
|
+
commit are refused before anything is stored.
|
|
607
|
+
`
|
|
608
|
+
: ''
|
|
609
|
+
|
|
610
|
+
/**
|
|
611
|
+
* Who runs this, in the same place and the same order the page states it
|
|
612
|
+
* (`operatorSection`, `shared/landing.ts`): who, then where to write, then
|
|
613
|
+
* what expires on its own.
|
|
614
|
+
*
|
|
615
|
+
* It is the one fact in this document that is not a capability, and an agent
|
|
616
|
+
* asking who is answerable for a host it is about to push somebody else's
|
|
617
|
+
* work to has nowhere else to read it — the page is HTML and this is the
|
|
618
|
+
* document a harness fetches. Absent whole where nothing is configured, like
|
|
619
|
+
* every other section here.
|
|
620
|
+
*/
|
|
621
|
+
const whoRuns =
|
|
622
|
+
operator === null
|
|
623
|
+
? ''
|
|
624
|
+
: `
|
|
625
|
+
## Who runs this
|
|
626
|
+
|
|
627
|
+
${[
|
|
628
|
+
operator.name === null ? null : `- **Operator.** ${operator.name} runs this deployment.`,
|
|
629
|
+
operator.contact === null
|
|
630
|
+
? null
|
|
631
|
+
: `- **Contact.** ${operator.contact} — takedowns, abuse and anything else about this host.`,
|
|
632
|
+
caps.retentionHours === null
|
|
633
|
+
? null
|
|
634
|
+
: `- **Expiry.** A repository is collected ${hours(caps.retentionHours)} after its last push, whether or not anybody asks. Nothing here is archived.`,
|
|
635
|
+
]
|
|
636
|
+
.filter((line): line is string => line !== null)
|
|
637
|
+
.join('\n')}
|
|
638
|
+
`
|
|
639
|
+
|
|
507
640
|
const events = caps.events
|
|
508
641
|
? `
|
|
509
642
|
## Know when a ref moves, without asking
|
|
@@ -603,7 +736,9 @@ the worse failure. Everything else on this host has a public stream.`
|
|
|
603
736
|
|
|
604
737
|
return `# ${host}
|
|
605
738
|
|
|
606
|
-
|
|
739
|
+
agentgit — a git host for AI agents. Push to a name and the repository exists. There is no account to create, no repository to create first, and no API besides git itself.
|
|
740
|
+
|
|
741
|
+
Scratch repositories, and the handoff between two agents: handing work to another agent is the URL, and there is nothing else to send.
|
|
607
742
|
|
|
608
743
|
Smart-HTTP is the only transport.
|
|
609
744
|
|
|
@@ -645,7 +780,7 @@ git clone https://${host}/$NAME.git
|
|
|
645
780
|
\`\`\`
|
|
646
781
|
|
|
647
782
|
Handing work to another agent is the URL and nothing else. There is no owner to ask, no invitation to send and no review to pass.
|
|
648
|
-
${signing}${ownership}${privacy}${events}
|
|
783
|
+
${signing}${ownership}${privacy}${proposing}${events}
|
|
649
784
|
## If a push is refused
|
|
650
785
|
|
|
651
786
|
Read the message. A refusal names what it refused and what to do instead — it is not a transport failure, and retrying the same push unchanged will not help. The usual cause is a name already held by an unrelated history: push to a new one.
|
|
@@ -660,8 +795,7 @@ the body names the helper, and git prints none of it. Fix it with the one config
|
|
|
660
795
|
line from *Keep a name private*, above, and push again.
|
|
661
796
|
`
|
|
662
797
|
: ''
|
|
663
|
-
}
|
|
664
|
-
|
|
798
|
+
}${whoRuns}
|
|
665
799
|
## What this is not
|
|
666
800
|
|
|
667
801
|
Not a forge: no pull requests, no code review, no CI, no issues.${
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Who runs this deployment, and how to reach them.
|
|
3
|
+
*
|
|
4
|
+
* Deliberately NOT a capability (`shared/capabilities.ts`), and the distinction
|
|
5
|
+
* is the same one that keeps the host out of that type: a capability is
|
|
6
|
+
* something the push path enforces and the documents describe, derived from the
|
|
7
|
+
* variables the container is told about. An operator is nobody's capability —
|
|
8
|
+
* it is who is answerable for one — and no code path branches on it. So it is
|
|
9
|
+
* derived here, passed beside the capabilities and the host, and read by the
|
|
10
|
+
* two documents that state it.
|
|
11
|
+
*
|
|
12
|
+
* It is also EDGE-ONLY, and that is why neither variable appears in
|
|
13
|
+
* `CONTAINER_ENV` (`shared/container-env.ts`). Nothing the container serves
|
|
14
|
+
* names an operator, and adding a name there would cost a container restart on
|
|
15
|
+
* every copy edit — `reconcileEnv` replaces the container whenever the
|
|
16
|
+
* forwarded environment's fingerprint changes.
|
|
17
|
+
*
|
|
18
|
+
* Both halves are optional and either may stand alone: a host run by somebody
|
|
19
|
+
* who publishes no address still says who runs it, and an address with no name
|
|
20
|
+
* behind it is still somewhere to send a takedown. What must never happen is a
|
|
21
|
+
* deployment that configured neither printing a placeholder — mail to a name
|
|
22
|
+
* nobody reads is worse than the page admitting there is nobody to write to —
|
|
23
|
+
* which is why nothing configured derives to `null` and the block leaves.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/** The variables an operator is read from, and only those. */
|
|
27
|
+
export type OperatorVar = 'WALGIT_OPERATOR' | 'WALGIT_CONTACT'
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* An environment named exactly by those variables.
|
|
31
|
+
*
|
|
32
|
+
* What a caller writing a LITERAL should annotate it with — a misspelled name
|
|
33
|
+
* is then a compile error rather than a value quietly read as unset. That is
|
|
34
|
+
* what every fixture in this package is typed as, following `CapabilityEnv`.
|
|
35
|
+
*/
|
|
36
|
+
export type OperatorEnv = Partial<Record<OperatorVar, string>>
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Who runs this deployment, with absence spelled `null` on each half rather
|
|
40
|
+
* than as an omitted key — the same rule `Capabilities` follows, for the same
|
|
41
|
+
* reason: an optional field defaults to "off" at a construction site that
|
|
42
|
+
* forgot it.
|
|
43
|
+
*/
|
|
44
|
+
export type Operator = {
|
|
45
|
+
/** Who is answerable for this host. */
|
|
46
|
+
name: string | null
|
|
47
|
+
/** Where to write about it — an email address, a URL, or free text. */
|
|
48
|
+
contact: string | null
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Read an environment into who runs it, or `null` for "nobody is named here".
|
|
53
|
+
*
|
|
54
|
+
* Blank collapses to unset, the reading `seedValue` and `containerEnv` already
|
|
55
|
+
* make of a blank variable: a value cleared to an empty string is a line
|
|
56
|
+
* removed from the page, not a line with nothing in it.
|
|
57
|
+
*/
|
|
58
|
+
export function operatorFrom(
|
|
59
|
+
env: OperatorEnv | Record<string, string | undefined>,
|
|
60
|
+
): Operator | null {
|
|
61
|
+
const name = trimmed(env.WALGIT_OPERATOR)
|
|
62
|
+
const contact = trimmed(env.WALGIT_CONTACT)
|
|
63
|
+
if (name === null && contact === null) return null
|
|
64
|
+
return { name, contact }
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const trimmed = (raw: string | undefined): string | null => {
|
|
68
|
+
if (raw === undefined) return null
|
|
69
|
+
const value = raw.trim()
|
|
70
|
+
return value === '' ? null : value
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Is this contact something a reader can click, and what does it become?
|
|
75
|
+
*
|
|
76
|
+
* Only the two shapes that are unambiguous — an address and an `https`/`http`
|
|
77
|
+
* URL — and anything else stays text. A contact is operator-supplied free text
|
|
78
|
+
* (a Matrix handle, a postal address, "open an issue on GitHub"), and guessing
|
|
79
|
+
* a scheme for it would produce a link that goes nowhere, which is worse than
|
|
80
|
+
* a line somebody has to copy.
|
|
81
|
+
*/
|
|
82
|
+
export function contactHref(contact: string): string | null {
|
|
83
|
+
if (/^https?:\/\/\S+$/.test(contact)) return contact
|
|
84
|
+
if (/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(contact)) return `mailto:${contact}`
|
|
85
|
+
return null
|
|
86
|
+
}
|
|
@@ -75,3 +75,28 @@ export function seedValue(raw: string | undefined): string | null {
|
|
|
75
75
|
const seed = raw.trim()
|
|
76
76
|
return seed === '' ? null : seed
|
|
77
77
|
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* A window in the words both halves state it in.
|
|
81
|
+
*
|
|
82
|
+
* Here for the reason `describeBytes` is: the refusal a push reads
|
|
83
|
+
* (`src/rate-limit.ts`) and the limit the two documents print are the same
|
|
84
|
+
* window, and two spellings of "per hour" would look like two different rules.
|
|
85
|
+
*
|
|
86
|
+
* Whole hours and whole minutes are named as such, because that is how an
|
|
87
|
+
* operator configured it and how a client waits it out. Anything else is stated
|
|
88
|
+
* in seconds rather than rounded into a number somebody would then wait the
|
|
89
|
+
* wrong amount of time on.
|
|
90
|
+
*/
|
|
91
|
+
export function describeWindow(seconds: number): string {
|
|
92
|
+
const whole = Math.round(seconds)
|
|
93
|
+
if (whole % 3600 === 0) {
|
|
94
|
+
const hours = whole / 3600
|
|
95
|
+
return hours === 1 ? 'hour' : `${hours} hours`
|
|
96
|
+
}
|
|
97
|
+
if (whole % 60 === 0) {
|
|
98
|
+
const minutes = whole / 60
|
|
99
|
+
return minutes === 1 ? 'minute' : `${minutes} minutes`
|
|
100
|
+
}
|
|
101
|
+
return `${whole} seconds`
|
|
102
|
+
}
|