chainlesschain 0.143.0 → 0.152.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/src/commands/a2a.js +196 -28
- package/src/commands/activitypub.js +364 -27
- package/src/commands/agent-network.js +217 -0
- package/src/commands/agent.js +587 -103
- package/src/commands/audit.js +206 -0
- package/src/commands/automation.js +201 -0
- package/src/commands/bi.js +355 -27
- package/src/commands/bm25.js +111 -27
- package/src/commands/browse.js +403 -29
- package/src/commands/ccron.js +128 -28
- package/src/commands/chat.js +207 -0
- package/src/commands/codegen.js +207 -0
- package/src/commands/collab.js +211 -0
- package/src/commands/compliance.js +824 -34
- package/src/commands/compt.js +127 -29
- package/src/commands/consol.js +8 -2
- package/src/commands/cowork.js +783 -34
- package/src/commands/crosschain.js +182 -28
- package/src/commands/dao.js +182 -28
- package/src/commands/dbevo.js +227 -0
- package/src/commands/dev.js +207 -0
- package/src/commands/did-v2.js +217 -0
- package/src/commands/did.js +221 -0
- package/src/commands/dlp.js +385 -27
- package/src/commands/economy.js +205 -50
- package/src/commands/evolution.js +203 -50
- package/src/commands/evomap.js +387 -27
- package/src/commands/export.js +213 -0
- package/src/commands/federation.js +209 -0
- package/src/commands/fflag.js +74 -22
- package/src/commands/fusion.js +205 -0
- package/src/commands/git.js +177 -37
- package/src/commands/governance.js +209 -0
- package/src/commands/hardening.js +209 -0
- package/src/commands/hmemory.js +204 -50
- package/src/commands/hook.js +209 -0
- package/src/commands/import.js +209 -0
- package/src/commands/incentive.js +209 -0
- package/src/commands/inference.js +170 -34
- package/src/commands/infra.js +203 -0
- package/src/commands/instinct.js +209 -0
- package/src/commands/ipfs.js +207 -0
- package/src/commands/itbudget.js +149 -33
- package/src/commands/kg.js +206 -0
- package/src/commands/llm.js +217 -0
- package/src/commands/lowcode.js +195 -38
- package/src/commands/marketplace.js +206 -0
- package/src/commands/matrix.js +386 -27
- package/src/commands/mcp.js +217 -0
- package/src/commands/mcpscaf.js +145 -33
- package/src/commands/meminj.js +145 -33
- package/src/commands/memory.js +209 -0
- package/src/commands/multimodal.js +203 -0
- package/src/commands/nlprog.js +225 -0
- package/src/commands/nostr.js +387 -27
- package/src/commands/note.js +205 -0
- package/src/commands/ops.js +219 -0
- package/src/commands/orchestrate.js +217 -0
- package/src/commands/orchgov.js +144 -33
- package/src/commands/org.js +209 -0
- package/src/commands/p2p.js +209 -0
- package/src/commands/pdfp.js +109 -27
- package/src/commands/perception.js +209 -0
- package/src/commands/perf.js +169 -32
- package/src/commands/perm.js +144 -33
- package/src/commands/permmem.js +203 -0
- package/src/commands/pipeline.js +207 -52
- package/src/commands/planmode.js +141 -32
- package/src/commands/plugin-ecosystem.js +209 -0
- package/src/commands/pqc.js +213 -0
- package/src/commands/privacy.js +203 -0
- package/src/commands/promcomp.js +111 -27
- package/src/commands/quantization.js +207 -0
- package/src/commands/rcache.js +205 -0
- package/src/commands/recommend.js +410 -34
- package/src/commands/reputation.js +208 -0
- package/src/commands/runtime.js +205 -0
- package/src/commands/sandbox.js +206 -0
- package/src/commands/scim.js +209 -0
- package/src/commands/seshhook.js +145 -33
- package/src/commands/seshsearch.js +141 -33
- package/src/commands/seshtail.js +144 -33
- package/src/commands/seshu.js +152 -33
- package/src/commands/session.js +209 -0
- package/src/commands/sganal.js +123 -29
- package/src/commands/siem.js +201 -34
- package/src/commands/skill.js +207 -0
- package/src/commands/sla.js +212 -0
- package/src/commands/slotfill.js +146 -33
- package/src/commands/social.js +358 -32
- package/src/commands/sso.js +209 -0
- package/src/commands/stress.js +206 -0
- package/src/commands/svccont.js +145 -33
- package/src/commands/sync.js +209 -0
- package/src/commands/tech.js +209 -0
- package/src/commands/tenant.js +217 -0
- package/src/commands/terraform.js +206 -0
- package/src/commands/tms.js +171 -33
- package/src/commands/tokens.js +209 -0
- package/src/commands/topiccls.js +146 -33
- package/src/commands/trust.js +217 -0
- package/src/commands/uprof.js +141 -32
- package/src/commands/vcheck.js +122 -28
- package/src/commands/wallet.js +209 -0
- package/src/commands/webfetch.js +141 -32
- package/src/commands/workflow.js +203 -0
- package/src/commands/zkp.js +184 -28
- package/src/index.js +180 -0
- package/src/lib/a2a-protocol.js +319 -51
- package/src/lib/activitypub-bridge.js +622 -50
- package/src/lib/agent-economy.js +304 -51
- package/src/lib/agent-network.js +341 -0
- package/src/lib/aiops.js +346 -0
- package/src/lib/app-builder.js +279 -46
- package/src/lib/audit-logger.js +321 -0
- package/src/lib/automation-engine.js +335 -0
- package/src/lib/autonomous-agent.js +284 -48
- package/src/lib/autonomous-developer.js +332 -0
- package/src/lib/bi-engine.js +616 -49
- package/src/lib/bm25-search.js +301 -49
- package/src/lib/browser-automation.js +630 -49
- package/src/lib/chat-core.js +336 -0
- package/src/lib/claude-code-bridge.js +341 -0
- package/src/lib/code-agent.js +339 -0
- package/src/lib/collaboration-governance.js +334 -0
- package/src/lib/community-governance.js +346 -0
- package/src/lib/compliance-framework-reporter.js +305 -51
- package/src/lib/compliance-manager.js +330 -0
- package/src/lib/compression-telemetry.js +301 -49
- package/src/lib/content-recommendation.js +351 -0
- package/src/lib/content-recommender.js +317 -52
- package/src/lib/cowork-cron.js +298 -49
- package/src/lib/cowork-learning.js +333 -0
- package/src/lib/cowork-share.js +338 -0
- package/src/lib/cowork-task-runner.js +308 -51
- package/src/lib/cowork-workflow.js +327 -0
- package/src/lib/cross-chain.js +311 -51
- package/src/lib/dao-governance.js +280 -46
- package/src/lib/dbevo.js +351 -0
- package/src/lib/decentral-infra.js +330 -0
- package/src/lib/did-manager.js +341 -0
- package/src/lib/did-v2-manager.js +341 -0
- package/src/lib/dlp-engine.js +626 -49
- package/src/lib/evolution-system.js +278 -47
- package/src/lib/evomap-governance.js +334 -0
- package/src/lib/evomap-manager.js +280 -46
- package/src/lib/execution-backend.js +294 -48
- package/src/lib/feature-flags.js +294 -49
- package/src/lib/federation-hardening.js +340 -0
- package/src/lib/git-integration.js +285 -47
- package/src/lib/hardening-manager.js +341 -0
- package/src/lib/hierarchical-memory.js +284 -48
- package/src/lib/hook-manager.js +341 -0
- package/src/lib/inference-network.js +308 -51
- package/src/lib/instinct-manager.js +346 -0
- package/src/lib/ipfs-storage.js +334 -0
- package/src/lib/iteration-budget.js +302 -50
- package/src/lib/knowledge-exporter.js +341 -0
- package/src/lib/knowledge-graph.js +333 -0
- package/src/lib/knowledge-importer.js +341 -0
- package/src/lib/llm-providers.js +346 -0
- package/src/lib/matrix-bridge.js +620 -47
- package/src/lib/mcp-registry.js +346 -0
- package/src/lib/mcp-scaffold.js +318 -54
- package/src/lib/memory-injection.js +288 -49
- package/src/lib/memory-manager.js +336 -0
- package/src/lib/multimodal.js +330 -0
- package/src/lib/nl-programming.js +341 -0
- package/src/lib/nostr-bridge.js +622 -49
- package/src/lib/note-versioning.js +339 -0
- package/src/lib/orchestrator.js +293 -48
- package/src/lib/org-manager.js +336 -0
- package/src/lib/p2p-manager.js +341 -0
- package/src/lib/pdf-parser.js +298 -49
- package/src/lib/perception.js +346 -0
- package/src/lib/perf-tuning.js +309 -50
- package/src/lib/permanent-memory.js +327 -0
- package/src/lib/permission-engine.js +287 -49
- package/src/lib/pipeline-orchestrator.js +289 -49
- package/src/lib/plan-mode.js +298 -51
- package/src/lib/plugin-ecosystem.js +346 -0
- package/src/lib/pqc-manager.js +346 -0
- package/src/lib/privacy-computing.js +335 -0
- package/src/lib/protocol-fusion.js +338 -0
- package/src/lib/quantization.js +337 -0
- package/src/lib/reputation-optimizer.js +340 -0
- package/src/lib/response-cache.js +333 -0
- package/src/lib/sandbox-v2.js +327 -0
- package/src/lib/scim-manager.js +346 -0
- package/src/lib/service-container.js +313 -52
- package/src/lib/session-consolidator.js +296 -49
- package/src/lib/session-hooks.js +312 -53
- package/src/lib/session-manager.js +334 -0
- package/src/lib/session-search.js +304 -51
- package/src/lib/session-tail.js +288 -49
- package/src/lib/session-usage.js +298 -52
- package/src/lib/siem-exporter.js +298 -51
- package/src/lib/skill-loader.js +334 -0
- package/src/lib/skill-marketplace.js +345 -0
- package/src/lib/sla-manager.js +341 -0
- package/src/lib/slot-filler.js +303 -51
- package/src/lib/social-graph-analytics.js +295 -49
- package/src/lib/social-graph.js +272 -49
- package/src/lib/social-manager.js +330 -0
- package/src/lib/sso-manager.js +340 -0
- package/src/lib/stress-tester.js +342 -0
- package/src/lib/sub-agent-registry.js +302 -53
- package/src/lib/sync-manager.js +336 -0
- package/src/lib/task-model-selector.js +302 -50
- package/src/lib/tech-learning-engine.js +341 -0
- package/src/lib/tenant-saas.js +341 -0
- package/src/lib/terraform-manager.js +333 -0
- package/src/lib/threat-intel.js +330 -0
- package/src/lib/todo-manager.js +281 -47
- package/src/lib/token-incentive.js +341 -0
- package/src/lib/token-tracker.js +336 -0
- package/src/lib/topic-classifier.js +297 -49
- package/src/lib/trust-security.js +343 -0
- package/src/lib/ueba.js +340 -0
- package/src/lib/universal-runtime.js +330 -0
- package/src/lib/user-profile.js +294 -50
- package/src/lib/version-checker.js +304 -50
- package/src/lib/wallet-manager.js +336 -0
- package/src/lib/web-fetch.js +292 -51
- package/src/lib/workflow-engine.js +330 -0
- package/src/lib/zkp-engine.js +286 -49
|
@@ -219,25 +219,56 @@ echo "ChainlessChain: pre-commit hook running"
|
|
|
219
219
|
return { installed: true, hook: "pre-commit", path: hookPath };
|
|
220
220
|
}
|
|
221
221
|
|
|
222
|
-
|
|
223
222
|
// ===== V2 Surface: Git Integration governance overlay (CLI v0.139.0) =====
|
|
224
223
|
export const GIT_REPO_MATURITY_V2 = Object.freeze({
|
|
225
|
-
PENDING: "pending",
|
|
224
|
+
PENDING: "pending",
|
|
225
|
+
ACTIVE: "active",
|
|
226
|
+
ARCHIVED: "archived",
|
|
227
|
+
DECOMMISSIONED: "decommissioned",
|
|
226
228
|
});
|
|
227
229
|
export const GIT_COMMIT_LIFECYCLE_V2 = Object.freeze({
|
|
228
|
-
QUEUED: "queued",
|
|
230
|
+
QUEUED: "queued",
|
|
231
|
+
COMMITTING: "committing",
|
|
232
|
+
COMMITTED: "committed",
|
|
233
|
+
FAILED: "failed",
|
|
234
|
+
CANCELLED: "cancelled",
|
|
229
235
|
});
|
|
230
236
|
|
|
231
237
|
const _grTrans = new Map([
|
|
232
|
-
[
|
|
233
|
-
|
|
234
|
-
|
|
238
|
+
[
|
|
239
|
+
GIT_REPO_MATURITY_V2.PENDING,
|
|
240
|
+
new Set([GIT_REPO_MATURITY_V2.ACTIVE, GIT_REPO_MATURITY_V2.DECOMMISSIONED]),
|
|
241
|
+
],
|
|
242
|
+
[
|
|
243
|
+
GIT_REPO_MATURITY_V2.ACTIVE,
|
|
244
|
+
new Set([
|
|
245
|
+
GIT_REPO_MATURITY_V2.ARCHIVED,
|
|
246
|
+
GIT_REPO_MATURITY_V2.DECOMMISSIONED,
|
|
247
|
+
]),
|
|
248
|
+
],
|
|
249
|
+
[
|
|
250
|
+
GIT_REPO_MATURITY_V2.ARCHIVED,
|
|
251
|
+
new Set([GIT_REPO_MATURITY_V2.ACTIVE, GIT_REPO_MATURITY_V2.DECOMMISSIONED]),
|
|
252
|
+
],
|
|
235
253
|
[GIT_REPO_MATURITY_V2.DECOMMISSIONED, new Set()],
|
|
236
254
|
]);
|
|
237
255
|
const _grTerminal = new Set([GIT_REPO_MATURITY_V2.DECOMMISSIONED]);
|
|
238
256
|
const _gcTrans = new Map([
|
|
239
|
-
[
|
|
240
|
-
|
|
257
|
+
[
|
|
258
|
+
GIT_COMMIT_LIFECYCLE_V2.QUEUED,
|
|
259
|
+
new Set([
|
|
260
|
+
GIT_COMMIT_LIFECYCLE_V2.COMMITTING,
|
|
261
|
+
GIT_COMMIT_LIFECYCLE_V2.CANCELLED,
|
|
262
|
+
]),
|
|
263
|
+
],
|
|
264
|
+
[
|
|
265
|
+
GIT_COMMIT_LIFECYCLE_V2.COMMITTING,
|
|
266
|
+
new Set([
|
|
267
|
+
GIT_COMMIT_LIFECYCLE_V2.COMMITTED,
|
|
268
|
+
GIT_COMMIT_LIFECYCLE_V2.FAILED,
|
|
269
|
+
GIT_COMMIT_LIFECYCLE_V2.CANCELLED,
|
|
270
|
+
]),
|
|
271
|
+
],
|
|
241
272
|
[GIT_COMMIT_LIFECYCLE_V2.COMMITTED, new Set()],
|
|
242
273
|
[GIT_COMMIT_LIFECYCLE_V2.FAILED, new Set()],
|
|
243
274
|
[GIT_COMMIT_LIFECYCLE_V2.CANCELLED, new Set()],
|
|
@@ -250,21 +281,45 @@ let _grMaxPendingCommitsPerRepo = 20;
|
|
|
250
281
|
let _grIdleMs = 30 * 24 * 60 * 60 * 1000;
|
|
251
282
|
let _gcStuckMs = 5 * 60 * 1000;
|
|
252
283
|
|
|
253
|
-
function _grPos(n, lbl) {
|
|
284
|
+
function _grPos(n, lbl) {
|
|
285
|
+
const v = Math.floor(Number(n));
|
|
286
|
+
if (!Number.isFinite(v) || v <= 0)
|
|
287
|
+
throw new Error(`${lbl} must be positive integer`);
|
|
288
|
+
return v;
|
|
289
|
+
}
|
|
254
290
|
|
|
255
|
-
export function setMaxActiveGitReposPerOwnerV2(n) {
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
export function
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
export function
|
|
262
|
-
|
|
291
|
+
export function setMaxActiveGitReposPerOwnerV2(n) {
|
|
292
|
+
_grMaxActivePerOwner = _grPos(n, "maxActiveGitReposPerOwner");
|
|
293
|
+
}
|
|
294
|
+
export function getMaxActiveGitReposPerOwnerV2() {
|
|
295
|
+
return _grMaxActivePerOwner;
|
|
296
|
+
}
|
|
297
|
+
export function setMaxPendingGitCommitsPerRepoV2(n) {
|
|
298
|
+
_grMaxPendingCommitsPerRepo = _grPos(n, "maxPendingGitCommitsPerRepo");
|
|
299
|
+
}
|
|
300
|
+
export function getMaxPendingGitCommitsPerRepoV2() {
|
|
301
|
+
return _grMaxPendingCommitsPerRepo;
|
|
302
|
+
}
|
|
303
|
+
export function setGitRepoIdleMsV2(n) {
|
|
304
|
+
_grIdleMs = _grPos(n, "gitRepoIdleMs");
|
|
305
|
+
}
|
|
306
|
+
export function getGitRepoIdleMsV2() {
|
|
307
|
+
return _grIdleMs;
|
|
308
|
+
}
|
|
309
|
+
export function setGitCommitStuckMsV2(n) {
|
|
310
|
+
_gcStuckMs = _grPos(n, "gitCommitStuckMs");
|
|
311
|
+
}
|
|
312
|
+
export function getGitCommitStuckMsV2() {
|
|
313
|
+
return _gcStuckMs;
|
|
314
|
+
}
|
|
263
315
|
|
|
264
316
|
export function _resetStateGitIntegrationV2() {
|
|
265
|
-
_grsV2.clear();
|
|
266
|
-
|
|
267
|
-
|
|
317
|
+
_grsV2.clear();
|
|
318
|
+
_gcsV2.clear();
|
|
319
|
+
_grMaxActivePerOwner = 10;
|
|
320
|
+
_grMaxPendingCommitsPerRepo = 20;
|
|
321
|
+
_grIdleMs = 30 * 24 * 60 * 60 * 1000;
|
|
322
|
+
_gcStuckMs = 5 * 60 * 1000;
|
|
268
323
|
}
|
|
269
324
|
|
|
270
325
|
export function registerGitRepoV2({ id, owner, branch, metadata } = {}) {
|
|
@@ -272,54 +327,237 @@ export function registerGitRepoV2({ id, owner, branch, metadata } = {}) {
|
|
|
272
327
|
if (!owner || typeof owner !== "string") throw new Error("owner is required");
|
|
273
328
|
if (_grsV2.has(id)) throw new Error(`git repo ${id} already registered`);
|
|
274
329
|
const now = Date.now();
|
|
275
|
-
const r = {
|
|
330
|
+
const r = {
|
|
331
|
+
id,
|
|
332
|
+
owner,
|
|
333
|
+
branch: branch || "main",
|
|
334
|
+
status: GIT_REPO_MATURITY_V2.PENDING,
|
|
335
|
+
createdAt: now,
|
|
336
|
+
updatedAt: now,
|
|
337
|
+
activatedAt: null,
|
|
338
|
+
decommissionedAt: null,
|
|
339
|
+
lastTouchedAt: now,
|
|
340
|
+
metadata: { ...(metadata || {}) },
|
|
341
|
+
};
|
|
276
342
|
_grsV2.set(id, r);
|
|
277
343
|
return { ...r, metadata: { ...r.metadata } };
|
|
278
344
|
}
|
|
279
|
-
function _grCheckR(from, to) {
|
|
280
|
-
|
|
345
|
+
function _grCheckR(from, to) {
|
|
346
|
+
const a = _grTrans.get(from);
|
|
347
|
+
if (!a || !a.has(to))
|
|
348
|
+
throw new Error(`invalid git repo transition ${from} → ${to}`);
|
|
349
|
+
}
|
|
350
|
+
function _grCountActive(owner) {
|
|
351
|
+
let n = 0;
|
|
352
|
+
for (const r of _grsV2.values())
|
|
353
|
+
if (r.owner === owner && r.status === GIT_REPO_MATURITY_V2.ACTIVE) n++;
|
|
354
|
+
return n;
|
|
355
|
+
}
|
|
281
356
|
|
|
282
357
|
export function activateGitRepoV2(id) {
|
|
283
|
-
const r = _grsV2.get(id);
|
|
358
|
+
const r = _grsV2.get(id);
|
|
359
|
+
if (!r) throw new Error(`git repo ${id} not found`);
|
|
284
360
|
_grCheckR(r.status, GIT_REPO_MATURITY_V2.ACTIVE);
|
|
285
361
|
const recovery = r.status === GIT_REPO_MATURITY_V2.ARCHIVED;
|
|
286
|
-
if (!recovery) {
|
|
287
|
-
|
|
362
|
+
if (!recovery) {
|
|
363
|
+
const c = _grCountActive(r.owner);
|
|
364
|
+
if (c >= _grMaxActivePerOwner)
|
|
365
|
+
throw new Error(
|
|
366
|
+
`max active git repos per owner (${_grMaxActivePerOwner}) reached for ${r.owner}`,
|
|
367
|
+
);
|
|
368
|
+
}
|
|
369
|
+
const now = Date.now();
|
|
370
|
+
r.status = GIT_REPO_MATURITY_V2.ACTIVE;
|
|
371
|
+
r.updatedAt = now;
|
|
372
|
+
r.lastTouchedAt = now;
|
|
373
|
+
if (!r.activatedAt) r.activatedAt = now;
|
|
374
|
+
return { ...r, metadata: { ...r.metadata } };
|
|
375
|
+
}
|
|
376
|
+
export function archiveGitRepoV2(id) {
|
|
377
|
+
const r = _grsV2.get(id);
|
|
378
|
+
if (!r) throw new Error(`git repo ${id} not found`);
|
|
379
|
+
_grCheckR(r.status, GIT_REPO_MATURITY_V2.ARCHIVED);
|
|
380
|
+
r.status = GIT_REPO_MATURITY_V2.ARCHIVED;
|
|
381
|
+
r.updatedAt = Date.now();
|
|
382
|
+
return { ...r, metadata: { ...r.metadata } };
|
|
383
|
+
}
|
|
384
|
+
export function decommissionGitRepoV2(id) {
|
|
385
|
+
const r = _grsV2.get(id);
|
|
386
|
+
if (!r) throw new Error(`git repo ${id} not found`);
|
|
387
|
+
_grCheckR(r.status, GIT_REPO_MATURITY_V2.DECOMMISSIONED);
|
|
388
|
+
const now = Date.now();
|
|
389
|
+
r.status = GIT_REPO_MATURITY_V2.DECOMMISSIONED;
|
|
390
|
+
r.updatedAt = now;
|
|
391
|
+
if (!r.decommissionedAt) r.decommissionedAt = now;
|
|
392
|
+
return { ...r, metadata: { ...r.metadata } };
|
|
393
|
+
}
|
|
394
|
+
export function touchGitRepoV2(id) {
|
|
395
|
+
const r = _grsV2.get(id);
|
|
396
|
+
if (!r) throw new Error(`git repo ${id} not found`);
|
|
397
|
+
if (_grTerminal.has(r.status))
|
|
398
|
+
throw new Error(`cannot touch terminal git repo ${id}`);
|
|
399
|
+
const now = Date.now();
|
|
400
|
+
r.lastTouchedAt = now;
|
|
401
|
+
r.updatedAt = now;
|
|
402
|
+
return { ...r, metadata: { ...r.metadata } };
|
|
403
|
+
}
|
|
404
|
+
export function getGitRepoV2(id) {
|
|
405
|
+
const r = _grsV2.get(id);
|
|
406
|
+
if (!r) return null;
|
|
288
407
|
return { ...r, metadata: { ...r.metadata } };
|
|
289
408
|
}
|
|
290
|
-
export function
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
409
|
+
export function listGitReposV2() {
|
|
410
|
+
return [..._grsV2.values()].map((r) => ({
|
|
411
|
+
...r,
|
|
412
|
+
metadata: { ...r.metadata },
|
|
413
|
+
}));
|
|
414
|
+
}
|
|
295
415
|
|
|
296
|
-
function _gcCountPending(repoId) {
|
|
416
|
+
function _gcCountPending(repoId) {
|
|
417
|
+
let n = 0;
|
|
418
|
+
for (const c of _gcsV2.values())
|
|
419
|
+
if (
|
|
420
|
+
c.repoId === repoId &&
|
|
421
|
+
(c.status === GIT_COMMIT_LIFECYCLE_V2.QUEUED ||
|
|
422
|
+
c.status === GIT_COMMIT_LIFECYCLE_V2.COMMITTING)
|
|
423
|
+
)
|
|
424
|
+
n++;
|
|
425
|
+
return n;
|
|
426
|
+
}
|
|
297
427
|
|
|
298
428
|
export function createGitCommitV2({ id, repoId, message, metadata } = {}) {
|
|
299
429
|
if (!id || typeof id !== "string") throw new Error("id is required");
|
|
300
|
-
if (!repoId || typeof repoId !== "string")
|
|
430
|
+
if (!repoId || typeof repoId !== "string")
|
|
431
|
+
throw new Error("repoId is required");
|
|
301
432
|
if (_gcsV2.has(id)) throw new Error(`git commit ${id} already exists`);
|
|
302
433
|
if (!_grsV2.has(repoId)) throw new Error(`git repo ${repoId} not found`);
|
|
303
434
|
const pending = _gcCountPending(repoId);
|
|
304
|
-
if (pending >= _grMaxPendingCommitsPerRepo)
|
|
435
|
+
if (pending >= _grMaxPendingCommitsPerRepo)
|
|
436
|
+
throw new Error(
|
|
437
|
+
`max pending git commits per repo (${_grMaxPendingCommitsPerRepo}) reached for ${repoId}`,
|
|
438
|
+
);
|
|
305
439
|
const now = Date.now();
|
|
306
|
-
const c = {
|
|
440
|
+
const c = {
|
|
441
|
+
id,
|
|
442
|
+
repoId,
|
|
443
|
+
message: message || "",
|
|
444
|
+
status: GIT_COMMIT_LIFECYCLE_V2.QUEUED,
|
|
445
|
+
createdAt: now,
|
|
446
|
+
updatedAt: now,
|
|
447
|
+
startedAt: null,
|
|
448
|
+
settledAt: null,
|
|
449
|
+
metadata: { ...(metadata || {}) },
|
|
450
|
+
};
|
|
307
451
|
_gcsV2.set(id, c);
|
|
308
452
|
return { ...c, metadata: { ...c.metadata } };
|
|
309
453
|
}
|
|
310
|
-
function _gcCheckC(from, to) {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
export function
|
|
316
|
-
|
|
454
|
+
function _gcCheckC(from, to) {
|
|
455
|
+
const a = _gcTrans.get(from);
|
|
456
|
+
if (!a || !a.has(to))
|
|
457
|
+
throw new Error(`invalid git commit transition ${from} → ${to}`);
|
|
458
|
+
}
|
|
459
|
+
export function startGitCommitV2(id) {
|
|
460
|
+
const c = _gcsV2.get(id);
|
|
461
|
+
if (!c) throw new Error(`git commit ${id} not found`);
|
|
462
|
+
_gcCheckC(c.status, GIT_COMMIT_LIFECYCLE_V2.COMMITTING);
|
|
463
|
+
const now = Date.now();
|
|
464
|
+
c.status = GIT_COMMIT_LIFECYCLE_V2.COMMITTING;
|
|
465
|
+
c.updatedAt = now;
|
|
466
|
+
if (!c.startedAt) c.startedAt = now;
|
|
467
|
+
return { ...c, metadata: { ...c.metadata } };
|
|
468
|
+
}
|
|
469
|
+
export function commitGitCommitV2(id) {
|
|
470
|
+
const c = _gcsV2.get(id);
|
|
471
|
+
if (!c) throw new Error(`git commit ${id} not found`);
|
|
472
|
+
_gcCheckC(c.status, GIT_COMMIT_LIFECYCLE_V2.COMMITTED);
|
|
473
|
+
const now = Date.now();
|
|
474
|
+
c.status = GIT_COMMIT_LIFECYCLE_V2.COMMITTED;
|
|
475
|
+
c.updatedAt = now;
|
|
476
|
+
if (!c.settledAt) c.settledAt = now;
|
|
477
|
+
return { ...c, metadata: { ...c.metadata } };
|
|
478
|
+
}
|
|
479
|
+
export function failGitCommitV2(id, reason) {
|
|
480
|
+
const c = _gcsV2.get(id);
|
|
481
|
+
if (!c) throw new Error(`git commit ${id} not found`);
|
|
482
|
+
_gcCheckC(c.status, GIT_COMMIT_LIFECYCLE_V2.FAILED);
|
|
483
|
+
const now = Date.now();
|
|
484
|
+
c.status = GIT_COMMIT_LIFECYCLE_V2.FAILED;
|
|
485
|
+
c.updatedAt = now;
|
|
486
|
+
if (!c.settledAt) c.settledAt = now;
|
|
487
|
+
if (reason) c.metadata.failReason = String(reason);
|
|
488
|
+
return { ...c, metadata: { ...c.metadata } };
|
|
489
|
+
}
|
|
490
|
+
export function cancelGitCommitV2(id, reason) {
|
|
491
|
+
const c = _gcsV2.get(id);
|
|
492
|
+
if (!c) throw new Error(`git commit ${id} not found`);
|
|
493
|
+
_gcCheckC(c.status, GIT_COMMIT_LIFECYCLE_V2.CANCELLED);
|
|
494
|
+
const now = Date.now();
|
|
495
|
+
c.status = GIT_COMMIT_LIFECYCLE_V2.CANCELLED;
|
|
496
|
+
c.updatedAt = now;
|
|
497
|
+
if (!c.settledAt) c.settledAt = now;
|
|
498
|
+
if (reason) c.metadata.cancelReason = String(reason);
|
|
499
|
+
return { ...c, metadata: { ...c.metadata } };
|
|
500
|
+
}
|
|
501
|
+
export function getGitCommitV2(id) {
|
|
502
|
+
const c = _gcsV2.get(id);
|
|
503
|
+
if (!c) return null;
|
|
504
|
+
return { ...c, metadata: { ...c.metadata } };
|
|
505
|
+
}
|
|
506
|
+
export function listGitCommitsV2() {
|
|
507
|
+
return [..._gcsV2.values()].map((c) => ({
|
|
508
|
+
...c,
|
|
509
|
+
metadata: { ...c.metadata },
|
|
510
|
+
}));
|
|
511
|
+
}
|
|
317
512
|
|
|
318
|
-
export function autoArchiveIdleGitReposV2({ now } = {}) {
|
|
319
|
-
|
|
513
|
+
export function autoArchiveIdleGitReposV2({ now } = {}) {
|
|
514
|
+
const t = now ?? Date.now();
|
|
515
|
+
const flipped = [];
|
|
516
|
+
for (const r of _grsV2.values())
|
|
517
|
+
if (
|
|
518
|
+
r.status === GIT_REPO_MATURITY_V2.ACTIVE &&
|
|
519
|
+
t - r.lastTouchedAt >= _grIdleMs
|
|
520
|
+
) {
|
|
521
|
+
r.status = GIT_REPO_MATURITY_V2.ARCHIVED;
|
|
522
|
+
r.updatedAt = t;
|
|
523
|
+
flipped.push(r.id);
|
|
524
|
+
}
|
|
525
|
+
return { flipped, count: flipped.length };
|
|
526
|
+
}
|
|
527
|
+
export function autoFailStuckGitCommitsV2({ now } = {}) {
|
|
528
|
+
const t = now ?? Date.now();
|
|
529
|
+
const flipped = [];
|
|
530
|
+
for (const c of _gcsV2.values())
|
|
531
|
+
if (
|
|
532
|
+
c.status === GIT_COMMIT_LIFECYCLE_V2.COMMITTING &&
|
|
533
|
+
c.startedAt != null &&
|
|
534
|
+
t - c.startedAt >= _gcStuckMs
|
|
535
|
+
) {
|
|
536
|
+
c.status = GIT_COMMIT_LIFECYCLE_V2.FAILED;
|
|
537
|
+
c.updatedAt = t;
|
|
538
|
+
if (!c.settledAt) c.settledAt = t;
|
|
539
|
+
c.metadata.failReason = "auto-fail-stuck";
|
|
540
|
+
flipped.push(c.id);
|
|
541
|
+
}
|
|
542
|
+
return { flipped, count: flipped.length };
|
|
543
|
+
}
|
|
320
544
|
|
|
321
545
|
export function getGitIntegrationGovStatsV2() {
|
|
322
|
-
const reposByStatus = {};
|
|
323
|
-
|
|
324
|
-
|
|
546
|
+
const reposByStatus = {};
|
|
547
|
+
for (const s of Object.values(GIT_REPO_MATURITY_V2)) reposByStatus[s] = 0;
|
|
548
|
+
for (const r of _grsV2.values()) reposByStatus[r.status]++;
|
|
549
|
+
const commitsByStatus = {};
|
|
550
|
+
for (const s of Object.values(GIT_COMMIT_LIFECYCLE_V2))
|
|
551
|
+
commitsByStatus[s] = 0;
|
|
552
|
+
for (const c of _gcsV2.values()) commitsByStatus[c.status]++;
|
|
553
|
+
return {
|
|
554
|
+
totalGitReposV2: _grsV2.size,
|
|
555
|
+
totalGitCommitsV2: _gcsV2.size,
|
|
556
|
+
maxActiveGitReposPerOwner: _grMaxActivePerOwner,
|
|
557
|
+
maxPendingGitCommitsPerRepo: _grMaxPendingCommitsPerRepo,
|
|
558
|
+
gitRepoIdleMs: _grIdleMs,
|
|
559
|
+
gitCommitStuckMs: _gcStuckMs,
|
|
560
|
+
reposByStatus,
|
|
561
|
+
commitsByStatus,
|
|
562
|
+
};
|
|
325
563
|
}
|