devworkspace 0.5.1 → 0.5.2
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 +30 -2
- package/README.md +57 -509
- package/dist/agents/claude/adapter.js +0 -1
- package/dist/agents/claude/content.js +0 -1
- package/dist/agents/codex/adapter.js +0 -1
- package/dist/agents/copilot/adapter.js +0 -1
- package/dist/agents/cursor/adapter.js +0 -1
- package/dist/agents/index.js +0 -1
- package/dist/agents/shared.js +0 -1
- package/dist/agents/types.js +0 -1
- package/dist/cli/args.d.ts +16 -0
- package/dist/cli/args.js +5 -1
- package/dist/cli/help.js +59 -17
- package/dist/cli/main.js +0 -1
- package/dist/cli/prompt.d.ts +15 -0
- package/dist/cli/prompt.js +113 -0
- package/dist/cli/render.d.ts +10 -0
- package/dist/cli/render.js +174 -4
- package/dist/cli/run.d.ts +3 -0
- package/dist/cli/run.js +366 -17
- package/dist/config/feature-gate.d.ts +15 -0
- package/dist/config/feature-gate.js +77 -0
- package/dist/config/feature-registry.d.ts +49 -0
- package/dist/config/feature-registry.js +451 -0
- package/dist/config/schemas.js +0 -1
- package/dist/config/settings.d.ts +54 -0
- package/dist/config/settings.js +293 -0
- package/dist/config/validate.js +0 -1
- package/dist/core/artifacts.js +0 -1
- package/dist/core/contracts.js +0 -1
- package/dist/core/migrations.js +0 -1
- package/dist/core/version.js +0 -1
- package/dist/core/versioned.js +0 -1
- package/dist/core/workspace.d.ts +1 -0
- package/dist/core/workspace.js +1 -1
- package/dist/decisions/decision.js +0 -1
- package/dist/discovery/cache.js +0 -1
- package/dist/discovery/commands.js +0 -1
- package/dist/discovery/detect.js +0 -1
- package/dist/discovery/docs.js +0 -1
- package/dist/discovery/entrypoints.js +0 -1
- package/dist/discovery/ignore.js +0 -1
- package/dist/discovery/scan.js +0 -1
- package/dist/discovery/types.js +0 -1
- package/dist/dx/dashboard.js +2 -1
- package/dist/dx/guidance.js +0 -1
- package/dist/dx/guided-setup.d.ts +102 -0
- package/dist/dx/guided-setup.js +508 -0
- package/dist/dx/index.js +0 -1
- package/dist/dx/onboarding.js +0 -1
- package/dist/dx/types.js +0 -1
- package/dist/errors/index.js +0 -1
- package/dist/features/schema.js +0 -1
- package/dist/features/types.js +0 -1
- package/dist/features/validate.js +0 -1
- package/dist/git/git.js +0 -1
- package/dist/index.d.ts +15 -5
- package/dist/index.js +10 -2
- package/dist/integrations/adapters/agent-skills.js +0 -1
- package/dist/integrations/adapters/claudePlugin.js +0 -1
- package/dist/integrations/adapters/graphify.js +0 -1
- package/dist/integrations/adapters/omniroute.js +0 -1
- package/dist/integrations/adapters/pluginSkill.js +0 -1
- package/dist/integrations/adapters/ponytail.js +0 -1
- package/dist/integrations/exec.js +0 -1
- package/dist/integrations/index.js +0 -1
- package/dist/integrations/manager.d.ts +2 -1
- package/dist/integrations/manager.js +22 -3
- package/dist/integrations/notices.js +0 -1
- package/dist/integrations/persistentPath.js +0 -1
- package/dist/integrations/protect.js +0 -1
- package/dist/integrations/state.js +0 -1
- package/dist/integrations/types.d.ts +1 -1
- package/dist/integrations/types.js +1 -1
- package/dist/intelligence/agents/profiles.js +0 -1
- package/dist/intelligence/agents/registry.js +0 -1
- package/dist/intelligence/agents/types.js +0 -1
- package/dist/intelligence/observability/tracer.js +0 -1
- package/dist/intelligence/observability/types.js +0 -1
- package/dist/intelligence/orchestration/engine.d.ts +13 -4
- package/dist/intelligence/orchestration/engine.js +332 -54
- package/dist/intelligence/orchestration/lock-manager.js +0 -1
- package/dist/intelligence/orchestration/store.js +0 -1
- package/dist/intelligence/orchestration/types.d.ts +28 -1
- package/dist/intelligence/orchestration/types.js +0 -1
- package/dist/intelligence/routing/matcher.js +0 -1
- package/dist/intelligence/routing/router.js +0 -1
- package/dist/intelligence/routing/types.js +0 -1
- package/dist/intelligence/runtime/adk/adapter.js +1 -2
- package/dist/intelligence/runtime/adk/detector.js +0 -1
- package/dist/intelligence/runtime/auth-provider.d.ts +63 -0
- package/dist/intelligence/runtime/auth-provider.js +201 -0
- package/dist/intelligence/runtime/boundary.d.ts +118 -6
- package/dist/intelligence/runtime/boundary.js +720 -38
- package/dist/intelligence/runtime/changes.d.ts +59 -0
- package/dist/intelligence/runtime/changes.js +362 -0
- package/dist/intelligence/runtime/external.d.ts +1 -0
- package/dist/intelligence/runtime/external.js +9 -6
- package/dist/intelligence/runtime/native.js +0 -1
- package/dist/intelligence/runtime/types.d.ts +64 -2
- package/dist/intelligence/runtime/types.js +0 -1
- package/dist/intelligence/security/audit.js +8 -2
- package/dist/intelligence/security/policy.js +0 -1
- package/dist/intelligence/security/types.d.ts +8 -0
- package/dist/intelligence/security/types.js +0 -1
- package/dist/intelligence/skills/builtins.js +0 -1
- package/dist/intelligence/skills/loader.js +0 -1
- package/dist/intelligence/skills/registry.js +0 -1
- package/dist/intelligence/skills/types.js +0 -1
- package/dist/intelligence/verification/engine.d.ts +10 -2
- package/dist/intelligence/verification/engine.js +53 -9
- package/dist/intelligence/verification/reviewer.d.ts +18 -2
- package/dist/intelligence/verification/reviewer.js +356 -4
- package/dist/intelligence/verification/types.d.ts +60 -0
- package/dist/intelligence/verification/types.js +0 -1
- package/dist/knowledge/facts.js +0 -1
- package/dist/mcp/protocol.js +0 -1
- package/dist/mcp/server.js +38 -2
- package/dist/mcp/setup.js +5 -2
- package/dist/mcp/tools.js +0 -1
- package/dist/mcp/types.js +0 -1
- package/dist/mcp/verify.js +0 -1
- package/dist/portability/bundle.js +0 -1
- package/dist/prompts/onboarding.js +0 -1
- package/dist/prompts/refresh.js +0 -1
- package/dist/prompts/requirements.js +0 -1
- package/dist/security/files.js +0 -1
- package/dist/security/redact.js +0 -1
- package/dist/services/agent.js +2 -1
- package/dist/services/analysis.js +0 -1
- package/dist/services/common.js +0 -1
- package/dist/services/doctor.js +13 -2
- package/dist/services/drift.js +0 -1
- package/dist/services/features.js +5 -1
- package/dist/services/graph.js +4 -1
- package/dist/services/init.js +0 -1
- package/dist/services/integrations.d.ts +2 -1
- package/dist/services/integrations.js +29 -6
- package/dist/services/intelligence.d.ts +2 -2
- package/dist/services/intelligence.js +38 -36
- package/dist/services/knowledge.js +0 -1
- package/dist/services/migrate.js +0 -1
- package/dist/services/modules.d.ts +85 -0
- package/dist/services/modules.js +313 -0
- package/dist/services/portability.js +0 -1
- package/dist/services/records.js +5 -1
- package/dist/services/refresh.js +0 -1
- package/dist/services/reset.js +0 -1
- package/dist/services/settings.d.ts +36 -0
- package/dist/services/settings.js +102 -0
- package/dist/services/setup.d.ts +4 -5
- package/dist/services/setup.js +40 -28
- package/dist/services/standards.js +10 -1
- package/dist/services/status.js +0 -1
- package/dist/services/taskContext.js +0 -1
- package/dist/services/tasks.js +9 -1
- package/dist/services/verify.js +7 -2
- package/dist/sessions/session.js +0 -1
- package/dist/standards/acquisition/ingest.js +0 -1
- package/dist/standards/applicability/engine.js +0 -1
- package/dist/standards/builtin/code-quality.js +0 -1
- package/dist/standards/builtin/database-safety.js +0 -1
- package/dist/standards/builtin/index.js +0 -1
- package/dist/standards/builtin/security-baseline.js +0 -1
- package/dist/standards/builtin/testing-contracts.js +0 -1
- package/dist/standards/builtin/undo-kit.js +0 -1
- package/dist/standards/config/config.js +0 -1
- package/dist/standards/distribution/cache.js +0 -1
- package/dist/standards/distribution/index.js +0 -1
- package/dist/standards/distribution/keys.js +0 -1
- package/dist/standards/distribution/package.js +0 -1
- package/dist/standards/distribution/server.js +0 -1
- package/dist/standards/distribution/sync.js +0 -1
- package/dist/standards/distribution/types.js +0 -1
- package/dist/standards/engine/compliance.js +0 -1
- package/dist/standards/engine/engine.js +0 -1
- package/dist/standards/engine/reporter.js +0 -1
- package/dist/standards/index.js +0 -1
- package/dist/standards/registry/registry.js +0 -1
- package/dist/standards/schema/types.js +0 -1
- package/dist/standards/schema/validate.js +0 -1
- package/dist/standards/templates/index.js +0 -1
- package/dist/standards/validators/database.js +0 -1
- package/dist/standards/validators/quality.js +0 -1
- package/dist/standards/validators/registry.js +0 -1
- package/dist/standards/validators/security.js +0 -1
- package/dist/standards/validators/testing.js +0 -1
- package/dist/standards/validators/types.js +0 -1
- package/dist/standards/validators/undo-kit.js +0 -1
- package/dist/tasks/routing.js +0 -1
- package/dist/tasks/task.js +0 -1
- package/dist/utils/cleanup.js +0 -1
- package/dist/utils/fs.js +0 -1
- package/dist/utils/lock.js +92 -49
- package/dist/utils/logger.js +0 -1
- package/dist/utils/paths.js +0 -1
- package/dist/utils/proc.d.ts +8 -0
- package/dist/utils/proc.js +54 -46
- package/dist/verification/safety.js +0 -1
- package/dist/verification/scope.js +0 -1
- package/docs/architecture/global-standards-architecture.md +287 -0
- package/docs/archive/global-standards/GLOBAL_STANDARDS_AUDIT.md +99 -0
- package/docs/archive/global-standards/GLOBAL_STANDARDS_FINAL_STATUS.md +138 -0
- package/docs/archive/global-standards/GLOBAL_STANDARDS_IMPLEMENTATION_PLAN.md +100 -0
- package/docs/archive/global-standards/GLOBAL_STANDARDS_INDEPENDENT_AUDIT.md +219 -0
- package/docs/archive/global-standards/GLOBAL_STANDARDS_SECURITY_REPORT.md +184 -0
- package/docs/configuration.md +67 -0
- package/docs/contributing.md +15 -4
- package/docs/development/EXECUTION_STATE.md +50 -0
- package/docs/features.md +80 -0
- package/docs/getting-started.md +69 -111
- package/docs/guides/global-standards-migration.md +100 -0
- package/docs/integrations.md +7 -0
- package/docs/security/THIRD_PARTY_LICENSES.md +41 -0
- package/docs/testing/FINAL_CORRECTION_AND_CLEANUP_REPORT.md +92 -0
- package/docs/testing/global-standards-real-project-tests.md +218 -0
- package/docs/testing/global-standards-test-report.md +89 -0
- package/docs/testing/global-standards-verification-matrix.md +174 -0
- package/docs/troubleshooting.md +3 -0
- package/package.json +1 -1
- package/dist/agents/claude/adapter.js.map +0 -1
- package/dist/agents/claude/content.js.map +0 -1
- package/dist/agents/codex/adapter.js.map +0 -1
- package/dist/agents/copilot/adapter.js.map +0 -1
- package/dist/agents/cursor/adapter.js.map +0 -1
- package/dist/agents/index.js.map +0 -1
- package/dist/agents/shared.js.map +0 -1
- package/dist/agents/types.js.map +0 -1
- package/dist/cli/args.js.map +0 -1
- package/dist/cli/help.js.map +0 -1
- package/dist/cli/main.js.map +0 -1
- package/dist/cli/render.js.map +0 -1
- package/dist/cli/run.js.map +0 -1
- package/dist/config/schemas.js.map +0 -1
- package/dist/config/validate.js.map +0 -1
- package/dist/core/artifacts.js.map +0 -1
- package/dist/core/contracts.js.map +0 -1
- package/dist/core/migrations.js.map +0 -1
- package/dist/core/version.js.map +0 -1
- package/dist/core/versioned.js.map +0 -1
- package/dist/core/workspace.js.map +0 -1
- package/dist/decisions/decision.js.map +0 -1
- package/dist/discovery/cache.js.map +0 -1
- package/dist/discovery/commands.js.map +0 -1
- package/dist/discovery/detect.js.map +0 -1
- package/dist/discovery/docs.js.map +0 -1
- package/dist/discovery/entrypoints.js.map +0 -1
- package/dist/discovery/ignore.js.map +0 -1
- package/dist/discovery/scan.js.map +0 -1
- package/dist/discovery/types.js.map +0 -1
- package/dist/dx/dashboard.js.map +0 -1
- package/dist/dx/guidance.js.map +0 -1
- package/dist/dx/index.js.map +0 -1
- package/dist/dx/onboarding.js.map +0 -1
- package/dist/dx/types.js.map +0 -1
- package/dist/errors/index.js.map +0 -1
- package/dist/features/schema.js.map +0 -1
- package/dist/features/types.js.map +0 -1
- package/dist/features/validate.js.map +0 -1
- package/dist/git/git.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/integrations/adapters/agent-skills.js.map +0 -1
- package/dist/integrations/adapters/claudePlugin.js.map +0 -1
- package/dist/integrations/adapters/graphify.js.map +0 -1
- package/dist/integrations/adapters/omniroute.js.map +0 -1
- package/dist/integrations/adapters/pluginSkill.js.map +0 -1
- package/dist/integrations/adapters/ponytail.js.map +0 -1
- package/dist/integrations/exec.js.map +0 -1
- package/dist/integrations/index.js.map +0 -1
- package/dist/integrations/manager.js.map +0 -1
- package/dist/integrations/notices.js.map +0 -1
- package/dist/integrations/persistentPath.js.map +0 -1
- package/dist/integrations/protect.js.map +0 -1
- package/dist/integrations/state.js.map +0 -1
- package/dist/integrations/types.js.map +0 -1
- package/dist/intelligence/agents/profiles.js.map +0 -1
- package/dist/intelligence/agents/registry.js.map +0 -1
- package/dist/intelligence/agents/types.js.map +0 -1
- package/dist/intelligence/observability/tracer.js.map +0 -1
- package/dist/intelligence/observability/types.js.map +0 -1
- package/dist/intelligence/orchestration/engine.js.map +0 -1
- package/dist/intelligence/orchestration/lock-manager.js.map +0 -1
- package/dist/intelligence/orchestration/store.js.map +0 -1
- package/dist/intelligence/orchestration/types.js.map +0 -1
- package/dist/intelligence/routing/matcher.js.map +0 -1
- package/dist/intelligence/routing/router.js.map +0 -1
- package/dist/intelligence/routing/types.js.map +0 -1
- package/dist/intelligence/runtime/adk/adapter.js.map +0 -1
- package/dist/intelligence/runtime/adk/detector.js.map +0 -1
- package/dist/intelligence/runtime/boundary.js.map +0 -1
- package/dist/intelligence/runtime/external.js.map +0 -1
- package/dist/intelligence/runtime/native.js.map +0 -1
- package/dist/intelligence/runtime/types.js.map +0 -1
- package/dist/intelligence/security/audit.js.map +0 -1
- package/dist/intelligence/security/policy.js.map +0 -1
- package/dist/intelligence/security/types.js.map +0 -1
- package/dist/intelligence/skills/builtins.js.map +0 -1
- package/dist/intelligence/skills/loader.js.map +0 -1
- package/dist/intelligence/skills/registry.js.map +0 -1
- package/dist/intelligence/skills/types.js.map +0 -1
- package/dist/intelligence/verification/engine.js.map +0 -1
- package/dist/intelligence/verification/reviewer.js.map +0 -1
- package/dist/intelligence/verification/types.js.map +0 -1
- package/dist/knowledge/facts.js.map +0 -1
- package/dist/mcp/protocol.js.map +0 -1
- package/dist/mcp/server.js.map +0 -1
- package/dist/mcp/setup.js.map +0 -1
- package/dist/mcp/tools.js.map +0 -1
- package/dist/mcp/types.js.map +0 -1
- package/dist/mcp/verify.js.map +0 -1
- package/dist/portability/bundle.js.map +0 -1
- package/dist/prompts/onboarding.js.map +0 -1
- package/dist/prompts/refresh.js.map +0 -1
- package/dist/prompts/requirements.js.map +0 -1
- package/dist/security/files.js.map +0 -1
- package/dist/security/redact.js.map +0 -1
- package/dist/services/agent.js.map +0 -1
- package/dist/services/analysis.js.map +0 -1
- package/dist/services/common.js.map +0 -1
- package/dist/services/doctor.js.map +0 -1
- package/dist/services/drift.js.map +0 -1
- package/dist/services/features.js.map +0 -1
- package/dist/services/graph.js.map +0 -1
- package/dist/services/init.js.map +0 -1
- package/dist/services/integrations.js.map +0 -1
- package/dist/services/intelligence.js.map +0 -1
- package/dist/services/knowledge.js.map +0 -1
- package/dist/services/migrate.js.map +0 -1
- package/dist/services/portability.js.map +0 -1
- package/dist/services/records.js.map +0 -1
- package/dist/services/refresh.js.map +0 -1
- package/dist/services/reset.js.map +0 -1
- package/dist/services/setup.js.map +0 -1
- package/dist/services/standards.js.map +0 -1
- package/dist/services/status.js.map +0 -1
- package/dist/services/taskContext.js.map +0 -1
- package/dist/services/tasks.js.map +0 -1
- package/dist/services/verify.js.map +0 -1
- package/dist/sessions/session.js.map +0 -1
- package/dist/standards/acquisition/ingest.js.map +0 -1
- package/dist/standards/applicability/engine.js.map +0 -1
- package/dist/standards/builtin/code-quality.js.map +0 -1
- package/dist/standards/builtin/database-safety.js.map +0 -1
- package/dist/standards/builtin/index.js.map +0 -1
- package/dist/standards/builtin/security-baseline.js.map +0 -1
- package/dist/standards/builtin/testing-contracts.js.map +0 -1
- package/dist/standards/builtin/undo-kit.js.map +0 -1
- package/dist/standards/config/config.js.map +0 -1
- package/dist/standards/distribution/cache.js.map +0 -1
- package/dist/standards/distribution/index.js.map +0 -1
- package/dist/standards/distribution/keys.js.map +0 -1
- package/dist/standards/distribution/package.js.map +0 -1
- package/dist/standards/distribution/server.js.map +0 -1
- package/dist/standards/distribution/sync.js.map +0 -1
- package/dist/standards/distribution/types.js.map +0 -1
- package/dist/standards/engine/compliance.js.map +0 -1
- package/dist/standards/engine/engine.js.map +0 -1
- package/dist/standards/engine/reporter.js.map +0 -1
- package/dist/standards/index.js.map +0 -1
- package/dist/standards/registry/registry.js.map +0 -1
- package/dist/standards/schema/types.js.map +0 -1
- package/dist/standards/schema/validate.js.map +0 -1
- package/dist/standards/templates/index.js.map +0 -1
- package/dist/standards/validators/database.js.map +0 -1
- package/dist/standards/validators/quality.js.map +0 -1
- package/dist/standards/validators/registry.js.map +0 -1
- package/dist/standards/validators/security.js.map +0 -1
- package/dist/standards/validators/testing.js.map +0 -1
- package/dist/standards/validators/types.js.map +0 -1
- package/dist/standards/validators/undo-kit.js.map +0 -1
- package/dist/tasks/routing.js.map +0 -1
- package/dist/tasks/task.js.map +0 -1
- package/dist/utils/cleanup.js.map +0 -1
- package/dist/utils/fs.js.map +0 -1
- package/dist/utils/lock.js.map +0 -1
- package/dist/utils/logger.js.map +0 -1
- package/dist/utils/paths.js.map +0 -1
- package/dist/utils/proc.js.map +0 -1
- package/dist/verification/safety.js.map +0 -1
- package/dist/verification/scope.js.map +0 -1
package/dist/utils/lock.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { randomBytes } from 'node:crypto';
|
|
1
2
|
import { promises as fs, unlinkSync } from 'node:fs';
|
|
2
3
|
import path from 'node:path';
|
|
3
4
|
import { DevWorkspaceError } from '../errors/index.js';
|
|
4
5
|
import { ensureDir } from './fs.js';
|
|
5
6
|
import { onCleanup } from './cleanup.js';
|
|
7
|
+
const localLockQueues = new Map();
|
|
6
8
|
function pidAlive(pid) {
|
|
7
9
|
try {
|
|
8
10
|
process.kill(pid, 0);
|
|
@@ -18,68 +20,109 @@ export async function withLock(workspaceDir, fn, opts = {}) {
|
|
|
18
20
|
const staleMs = opts.staleMs ?? 60_000;
|
|
19
21
|
const dir = path.join(workspaceDir, 'local');
|
|
20
22
|
const lockPath = path.join(dir, opts.name ?? 'workspace.lock');
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
await new Promise((r) => setTimeout(r, 15 + Math.floor(Math.random() * 25)));
|
|
37
|
-
continue;
|
|
38
|
-
}
|
|
39
|
-
if (code !== 'EEXIST') {
|
|
40
|
-
throw new DevWorkspaceError('IO', 'Could not acquire the workspace lock.', { cause: e });
|
|
41
|
-
}
|
|
42
|
-
let stale;
|
|
23
|
+
const queueKey = process.platform === 'win32' ? path.resolve(lockPath).toLowerCase() : path.resolve(lockPath);
|
|
24
|
+
const myToken = randomBytes(8).toString('hex');
|
|
25
|
+
const previous = localLockQueues.get(queueKey) ?? Promise.resolve();
|
|
26
|
+
let releaseLocal;
|
|
27
|
+
const currentSlot = new Promise((resolve) => {
|
|
28
|
+
releaseLocal = resolve;
|
|
29
|
+
});
|
|
30
|
+
const chained = previous.then(() => currentSlot);
|
|
31
|
+
localLockQueues.set(queueKey, chained);
|
|
32
|
+
await previous;
|
|
33
|
+
try {
|
|
34
|
+
await ensureDir(dir);
|
|
35
|
+
const started = Date.now();
|
|
36
|
+
let winPermRetries = 0;
|
|
37
|
+
for (;;) {
|
|
43
38
|
try {
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
39
|
+
const fh = await fs.open(lockPath, 'wx');
|
|
40
|
+
try {
|
|
41
|
+
await fh.writeFile(JSON.stringify({ pid: process.pid, at: Date.now(), token: myToken }));
|
|
42
|
+
}
|
|
43
|
+
finally {
|
|
44
|
+
await fh.close();
|
|
45
|
+
}
|
|
46
|
+
break;
|
|
47
47
|
}
|
|
48
|
-
catch {
|
|
49
|
-
|
|
48
|
+
catch (e) {
|
|
49
|
+
const code = e.code;
|
|
50
|
+
// On Windows, opening a recently unlinked lock file while its handle is closing can briefly raise EPERM/EACCES.
|
|
51
|
+
if (process.platform === 'win32' && (code === 'EPERM' || code === 'EACCES') && winPermRetries < 25 && Date.now() - started <= timeoutMs) {
|
|
52
|
+
winPermRetries++;
|
|
53
|
+
await new Promise((r) => setTimeout(r, 15 + Math.floor(Math.random() * 25)));
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if (code !== 'EEXIST') {
|
|
57
|
+
throw new DevWorkspaceError('IO', 'Could not acquire the workspace lock.', { cause: e });
|
|
58
|
+
}
|
|
59
|
+
let stale = false;
|
|
60
|
+
let disappeared = false;
|
|
50
61
|
try {
|
|
51
|
-
|
|
62
|
+
const info = JSON.parse(await fs.readFile(lockPath, 'utf8'));
|
|
63
|
+
const age = Date.now() - (info.at ?? 0);
|
|
64
|
+
stale = age > staleMs || (typeof info.pid === 'number' && !pidAlive(info.pid));
|
|
52
65
|
}
|
|
53
66
|
catch {
|
|
54
|
-
|
|
67
|
+
// Unreadable lock: another process may be mid-write, or the lock was just released.
|
|
68
|
+
try {
|
|
69
|
+
stale = Date.now() - (await fs.stat(lockPath)).mtimeMs > 2000;
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
disappeared = true;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (disappeared) {
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
if (stale) {
|
|
79
|
+
const staleTrash = `${lockPath}.stale.${randomBytes(4).toString('hex')}`;
|
|
80
|
+
try {
|
|
81
|
+
await fs.rename(lockPath, staleTrash);
|
|
82
|
+
await fs.rm(staleTrash, { force: true }).catch(() => undefined);
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
// Another waiter already broke or removed the lock; retry cleanly.
|
|
86
|
+
}
|
|
87
|
+
continue;
|
|
55
88
|
}
|
|
89
|
+
if (Date.now() - started > timeoutMs) {
|
|
90
|
+
throw new DevWorkspaceError('LOCKED', 'Another DevWorkspace process is modifying this workspace.', {
|
|
91
|
+
hint: `Wait for it to finish, or delete ${path.join('.devworkspace', 'local', opts.name ?? 'workspace.lock')} if no process is running.`,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
await new Promise((r) => setTimeout(r, 25 + Math.floor(Math.random() * 50)));
|
|
56
95
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
96
|
+
}
|
|
97
|
+
const dispose = onCleanup(() => {
|
|
98
|
+
try {
|
|
99
|
+
unlinkSync(lockPath);
|
|
60
100
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
hint: `Wait for it to finish, or delete ${path.join('.devworkspace', 'local', opts.name ?? 'workspace.lock')} if no process is running.`,
|
|
64
|
-
});
|
|
101
|
+
catch {
|
|
102
|
+
/* already gone */
|
|
65
103
|
}
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
const dispose = onCleanup(() => {
|
|
104
|
+
});
|
|
70
105
|
try {
|
|
71
|
-
|
|
106
|
+
return await fn();
|
|
72
107
|
}
|
|
73
|
-
|
|
74
|
-
|
|
108
|
+
finally {
|
|
109
|
+
dispose();
|
|
110
|
+
try {
|
|
111
|
+
const raw = await fs.readFile(lockPath, 'utf8');
|
|
112
|
+
const info = JSON.parse(raw);
|
|
113
|
+
if (info.token === myToken) {
|
|
114
|
+
await fs.rm(lockPath, { force: true }).catch(() => undefined);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
// Lock was already removed (e.g. via cleanup hook or external stale break).
|
|
119
|
+
}
|
|
75
120
|
}
|
|
76
|
-
});
|
|
77
|
-
try {
|
|
78
|
-
return await fn();
|
|
79
121
|
}
|
|
80
122
|
finally {
|
|
81
|
-
|
|
82
|
-
|
|
123
|
+
releaseLocal();
|
|
124
|
+
if (localLockQueues.get(queueKey) === chained) {
|
|
125
|
+
localLockQueues.delete(queueKey);
|
|
126
|
+
}
|
|
83
127
|
}
|
|
84
128
|
}
|
|
85
|
-
//# sourceMappingURL=lock.js.map
|
package/dist/utils/logger.js
CHANGED
package/dist/utils/paths.js
CHANGED
package/dist/utils/proc.d.ts
CHANGED
|
@@ -22,6 +22,14 @@ export interface RunOptions {
|
|
|
22
22
|
}
|
|
23
23
|
/** Build a minimal process environment containing OS/runtime basics without leaking secrets. */
|
|
24
24
|
export declare function createMinimalExecutionEnv(baseEnv?: NodeJS.ProcessEnv, extraAllowKeys?: string[], overrides?: Record<string, string | undefined>): NodeJS.ProcessEnv;
|
|
25
|
+
/**
|
|
26
|
+
* Spawn an executable with an argument array without blocking on child exit until `done` is awaited.
|
|
27
|
+
* Never uses a shell, so project- or user-supplied values cannot be interpreted as shell syntax.
|
|
28
|
+
*/
|
|
29
|
+
export declare function startRun(command: string, args: string[], opts?: RunOptions): {
|
|
30
|
+
spawned: boolean;
|
|
31
|
+
done: Promise<RunResult>;
|
|
32
|
+
};
|
|
25
33
|
/**
|
|
26
34
|
* Run an executable with an argument array. Never uses a shell, so project- or
|
|
27
35
|
* user-supplied values cannot be interpreted as shell syntax.
|
package/dist/utils/proc.js
CHANGED
|
@@ -53,64 +53,65 @@ function killProcessTree(child) {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
/**
|
|
56
|
-
*
|
|
57
|
-
* user-supplied values cannot be interpreted as shell syntax.
|
|
56
|
+
* Spawn an executable with an argument array without blocking on child exit until `done` is awaited.
|
|
57
|
+
* Never uses a shell, so project- or user-supplied values cannot be interpreted as shell syntax.
|
|
58
58
|
*/
|
|
59
|
-
export function
|
|
59
|
+
export function startRun(command, args, opts = {}) {
|
|
60
60
|
const timeoutMs = opts.timeoutMs ?? 15_000;
|
|
61
61
|
const maxBytes = opts.maxBytes ?? 4 * 1024 * 1024;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
62
|
+
let stdout = '';
|
|
63
|
+
let stderr = '';
|
|
64
|
+
let timedOut = false;
|
|
65
|
+
let aborted = false;
|
|
66
|
+
let settled = false;
|
|
67
|
+
if (opts.signal?.aborted) {
|
|
68
|
+
return {
|
|
69
|
+
spawned: false,
|
|
70
|
+
done: Promise.resolve({ ok: false, code: null, stdout, stderr, timedOut: false, aborted: true, error: 'aborted' }),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
let child;
|
|
74
|
+
try {
|
|
75
|
+
const env = opts.replaceEnv
|
|
76
|
+
? { ...(opts.env ?? {}) }
|
|
77
|
+
: opts.env ? { ...process.env, ...opts.env } : process.env;
|
|
78
|
+
for (const [k, v] of Object.entries(env))
|
|
79
|
+
if (v === undefined)
|
|
80
|
+
delete env[k];
|
|
81
|
+
child = spawn(command, args, {
|
|
82
|
+
cwd: opts.cwd,
|
|
83
|
+
env,
|
|
84
|
+
shell: false,
|
|
85
|
+
windowsHide: true,
|
|
86
|
+
windowsVerbatimArguments: opts.windowsVerbatimArguments,
|
|
87
|
+
detached: process.platform !== 'win32',
|
|
88
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
catch (e) {
|
|
92
|
+
return {
|
|
93
|
+
spawned: false,
|
|
94
|
+
done: Promise.resolve({ ok: false, code: null, stdout, stderr, timedOut: false, error: e.message }),
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
const c = child;
|
|
98
|
+
const done = new Promise((resolve) => {
|
|
70
99
|
const onAbort = () => {
|
|
71
100
|
aborted = true;
|
|
72
|
-
killProcessTree(
|
|
101
|
+
killProcessTree(c);
|
|
73
102
|
};
|
|
103
|
+
const timer = setTimeout(() => {
|
|
104
|
+
timedOut = true;
|
|
105
|
+
killProcessTree(c);
|
|
106
|
+
}, timeoutMs);
|
|
74
107
|
const finish = (r) => {
|
|
75
108
|
if (settled)
|
|
76
109
|
return;
|
|
77
110
|
settled = true;
|
|
78
|
-
|
|
79
|
-
clearTimeout(timer);
|
|
111
|
+
clearTimeout(timer);
|
|
80
112
|
opts.signal?.removeEventListener('abort', onAbort);
|
|
81
113
|
resolve(aborted ? { ...r, ok: false, aborted: true } : r);
|
|
82
114
|
};
|
|
83
|
-
let child;
|
|
84
|
-
if (opts.signal?.aborted) {
|
|
85
|
-
finish({ ok: false, code: null, stdout, stderr, timedOut: false, aborted: true, error: 'aborted' });
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
try {
|
|
89
|
-
const env = opts.replaceEnv
|
|
90
|
-
? { ...(opts.env ?? {}) }
|
|
91
|
-
: opts.env ? { ...process.env, ...opts.env } : process.env;
|
|
92
|
-
for (const [k, v] of Object.entries(env))
|
|
93
|
-
if (v === undefined)
|
|
94
|
-
delete env[k];
|
|
95
|
-
child = spawn(command, args, {
|
|
96
|
-
cwd: opts.cwd,
|
|
97
|
-
env,
|
|
98
|
-
shell: false,
|
|
99
|
-
windowsHide: true,
|
|
100
|
-
windowsVerbatimArguments: opts.windowsVerbatimArguments,
|
|
101
|
-
detached: process.platform !== 'win32',
|
|
102
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
catch (e) {
|
|
106
|
-
finish({ ok: false, code: null, stdout, stderr, timedOut: false, error: e.message });
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
const c = child;
|
|
110
|
-
timer = setTimeout(() => {
|
|
111
|
-
timedOut = true;
|
|
112
|
-
killProcessTree(c);
|
|
113
|
-
}, timeoutMs);
|
|
114
115
|
opts.signal?.addEventListener('abort', onAbort, { once: true });
|
|
115
116
|
c.stdout?.on('data', (d) => {
|
|
116
117
|
if (stdout.length < maxBytes)
|
|
@@ -123,6 +124,14 @@ export function run(command, args, opts = {}) {
|
|
|
123
124
|
c.on('error', (e) => finish({ ok: false, code: null, stdout, stderr, timedOut, error: e.message }));
|
|
124
125
|
c.on('close', (code) => finish({ ok: code === 0 && !timedOut && !aborted, code, stdout, stderr, timedOut }));
|
|
125
126
|
});
|
|
127
|
+
return { spawned: true, done };
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Run an executable with an argument array. Never uses a shell, so project- or
|
|
131
|
+
* user-supplied values cannot be interpreted as shell syntax.
|
|
132
|
+
*/
|
|
133
|
+
export function run(command, args, opts = {}) {
|
|
134
|
+
return startRun(command, args, opts).done;
|
|
126
135
|
}
|
|
127
136
|
/** Locate an executable on PATH (honouring PATHEXT on Windows) without executing anything. */
|
|
128
137
|
export async function which(name, env = process.env) {
|
|
@@ -166,4 +175,3 @@ export async function which(name, env = process.env) {
|
|
|
166
175
|
export function isShellShim(file) {
|
|
167
176
|
return /\.(cmd|bat)$/i.test(file);
|
|
168
177
|
}
|
|
169
|
-
//# sourceMappingURL=proc.js.map
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
# DevWorkspace Global Engineering Standards & Knowledge System
|
|
2
|
+
## System Architecture & Technical Specification
|
|
3
|
+
|
|
4
|
+
**Version:** 1.0.0
|
|
5
|
+
**Status:** Approved Architecture
|
|
6
|
+
**Author:** Principal Software Architect & Senior TypeScript Engineer
|
|
7
|
+
**Date:** 2026-11-30
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 1. System Vision & High-Level Architecture
|
|
12
|
+
|
|
13
|
+
The **DevWorkspace Global Engineering Standards System** is a native, offline-first, technology-independent governance and quality engineering platform built directly into the DevWorkspace core.
|
|
14
|
+
|
|
15
|
+
It shifts software engineering governance from subjective manual guidelines or unpredictable LLM suggestions into deterministic, automated, version-controlled standards with executable validators.
|
|
16
|
+
|
|
17
|
+
```text
|
|
18
|
+
+------------------------------------------------------------------------------------------------+
|
|
19
|
+
| DEVWORKSPACE CLI & RUNTIME |
|
|
20
|
+
| devworkspace standards <list | show | audit | check | apply | add | update | report | validate> |
|
|
21
|
+
+------------------------------------------------------------------------------------------------+
|
|
22
|
+
|
|
|
23
|
+
v
|
|
24
|
+
+------------------------------------------------------------------------------------------------+
|
|
25
|
+
| STANDARDS SERVICE LAYER |
|
|
26
|
+
| (src/services/standards.ts) |
|
|
27
|
+
+------------------------------------------------------------------------------------------------+
|
|
28
|
+
| | |
|
|
29
|
+
v v v
|
|
30
|
+
+-----------------------+ +-----------------------+ +-----------------------+
|
|
31
|
+
| STANDARDS REGISTRY | | APPLICABILITY ENGINE | | VALIDATION ENGINE |
|
|
32
|
+
| (src/standards/ | | (src/standards/ | | (src/standards/ |
|
|
33
|
+
| registry/) | | applicability/) | | validators/) |
|
|
34
|
+
| | | | | |
|
|
35
|
+
| - Built-in Standards | | - Tech Detection | | - Security Validator |
|
|
36
|
+
| - Local Custom Rules | | - Arch Patterns | | - DB Migration Guard |
|
|
37
|
+
| - Version Management | | - Framework Rules | | - Testing Validator |
|
|
38
|
+
| - Lifecycle Transitions | - Applicability Match | | - Undo Kit Validator |
|
|
39
|
+
+-----------------------+ +-----------------------+ | - Code Quality Guard |
|
|
40
|
+
| | +-----------------------+
|
|
41
|
+
+-----------------+------------------+ |
|
|
42
|
+
v v
|
|
43
|
+
+------------------------------------------------------------------------------------------------+
|
|
44
|
+
| STANDARDS CORE ENGINE |
|
|
45
|
+
| (src/standards/engine/) |
|
|
46
|
+
| |
|
|
47
|
+
| 1. Configuration Inheritance: Global Defaults -> Tech-Specific -> Project -> Exceptions |
|
|
48
|
+
| 2. Compliance Scoring: (Passed Checks / Total Applicable Checks) * 100% |
|
|
49
|
+
| 3. Violation & Remediation Aggregator |
|
|
50
|
+
| 4. Markdown & JSON Compliance Report Generator |
|
|
51
|
+
+------------------------------------------------------------------------------------------------+
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## 2. Core Subsystems & Components
|
|
57
|
+
|
|
58
|
+
### 2.1 Standards Schema & Lifecycle (`src/standards/schema/types.ts`)
|
|
59
|
+
|
|
60
|
+
Every engineering standard is governed by a strict TypeScript schema:
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
export type StandardCategory =
|
|
64
|
+
| 'architecture'
|
|
65
|
+
| 'security'
|
|
66
|
+
| 'database'
|
|
67
|
+
| 'development'
|
|
68
|
+
| 'code-quality'
|
|
69
|
+
| 'testing'
|
|
70
|
+
| 'devops'
|
|
71
|
+
| 'deployment'
|
|
72
|
+
| 'performance'
|
|
73
|
+
| 'scalability'
|
|
74
|
+
| 'observability'
|
|
75
|
+
| 'documentation'
|
|
76
|
+
| 'accessibility'
|
|
77
|
+
| 'reliability'
|
|
78
|
+
| 'recovery';
|
|
79
|
+
|
|
80
|
+
export type StandardStatus =
|
|
81
|
+
| 'DRAFT'
|
|
82
|
+
| 'REVIEW'
|
|
83
|
+
| 'APPROVED'
|
|
84
|
+
| 'DEPRECATED'
|
|
85
|
+
| 'ARCHIVED';
|
|
86
|
+
|
|
87
|
+
export type EnforcementLevel =
|
|
88
|
+
| 'required'
|
|
89
|
+
| 'recommended'
|
|
90
|
+
| 'optional';
|
|
91
|
+
|
|
92
|
+
export interface ApplicabilityCriteria {
|
|
93
|
+
ecosystems?: string[]; // e.g. ['node', 'python', 'rust']
|
|
94
|
+
frameworks?: string[]; // e.g. ['express', 'fastify', 'react', 'nextjs']
|
|
95
|
+
databases?: string[]; // e.g. ['prisma', 'postgresql', 'supabase', 'mongodb']
|
|
96
|
+
platforms?: string[]; // e.g. ['vercel', 'netlify', 'docker', 'aws']
|
|
97
|
+
appTypes?: string[]; // e.g. ['api', 'spa', 'monorepo', 'cli']
|
|
98
|
+
filePatterns?: string[]; // e.g. ['prisma/schema.prisma', 'Dockerfile']
|
|
99
|
+
all?: boolean; // Universal standard (applies to all projects)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export interface StandardRule {
|
|
103
|
+
id: string; // e.g. 'deployment.backup-first'
|
|
104
|
+
title: string;
|
|
105
|
+
description: string;
|
|
106
|
+
severity: 'critical' | 'high' | 'medium' | 'low' | 'info';
|
|
107
|
+
enforcement: EnforcementLevel;
|
|
108
|
+
remediation: string;
|
|
109
|
+
validatorId?: string; // Linked executable validator ID
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface EngineeringStandard {
|
|
113
|
+
id: string; // kebab-case identifier, e.g. 'deployment-safety-and-rollback'
|
|
114
|
+
name: string;
|
|
115
|
+
description: string;
|
|
116
|
+
category: StandardCategory;
|
|
117
|
+
version: string; // semver string, e.g. '1.0.0'
|
|
118
|
+
status: StandardStatus;
|
|
119
|
+
applicability: ApplicabilityCriteria;
|
|
120
|
+
requirements: string[];
|
|
121
|
+
guidelines: string[];
|
|
122
|
+
rules: StandardRule[];
|
|
123
|
+
enforcement: EnforcementLevel;
|
|
124
|
+
references: string[];
|
|
125
|
+
metadata: {
|
|
126
|
+
createdAt: string;
|
|
127
|
+
updatedAt: string;
|
|
128
|
+
author: string;
|
|
129
|
+
tags: string[];
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
#### Lifecycle State Machine
|
|
135
|
+
```text
|
|
136
|
+
[ DRAFT ] ──(Submit for Review)──> [ REVIEW ] ──(Approved by Maintainer)──> [ APPROVED ]
|
|
137
|
+
│
|
|
138
|
+
(Superseded / Outdated)
|
|
139
|
+
│
|
|
140
|
+
v
|
|
141
|
+
[ ARCHIVED ] ◄────────────────(Final Archive)─────────────────────────── [ DEPRECATED ]
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
### 2.2 Standards Registry (`src/standards/registry/`)
|
|
147
|
+
The Standards Registry manages both built-in standards and local project/user custom standards:
|
|
148
|
+
- **Built-in Standards:** High-quality, peer-reviewed engineering standards bundled directly in the package (including `deployment-safety-and-rollback`, `security-baseline`, `database-expand-and-contract`, `testing-contract-safety`, `code-quality-static-analysis`).
|
|
149
|
+
- **Project Standards:** Stored under `.devworkspace/standards/custom/*.json`.
|
|
150
|
+
- **Global User Standards:** Stored under `~/.devworkspace/standards/*.json`.
|
|
151
|
+
- **Registry Capabilities:**
|
|
152
|
+
- `get(id: string)`: Retrieves standard by ID.
|
|
153
|
+
- `list(filter?)`: Returns all registered standards matching category or status.
|
|
154
|
+
- `validateRegistry()`: Guarantees structural integrity, unique IDs, valid semver, and matching validator IDs.
|
|
155
|
+
- `register(standard)`: Adds or overrides a standard definition.
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
### 2.3 Project Applicability Engine (`src/standards/applicability/`)
|
|
160
|
+
Determines which standards apply to the current project:
|
|
161
|
+
1. Reuses and inspects `DiscoveryReport` from `src/discovery/detect.ts`.
|
|
162
|
+
2. Matches project properties against each standard's `ApplicabilityCriteria`:
|
|
163
|
+
- Checks if `criteria.all === true`.
|
|
164
|
+
- Checks if any project ecosystem matches `criteria.ecosystems`.
|
|
165
|
+
- Checks if any detected framework or database matches `criteria.frameworks` or `criteria.databases`.
|
|
166
|
+
- Checks if required files exist (`criteria.filePatterns`).
|
|
167
|
+
3. Produces an `ApplicabilityResult`:
|
|
168
|
+
- `applicableStandards`: List of matching standards.
|
|
169
|
+
- `excludedStandards`: Standards not applicable, with transparent reasoning.
|
|
170
|
+
- `detectedTechnologies`: Summary of detected stacks.
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
### 2.4 Executable Validation Engine (`src/standards/validators/`)
|
|
175
|
+
Validators are **executable functions**, not passive text checklists:
|
|
176
|
+
|
|
177
|
+
```typescript
|
|
178
|
+
export interface ValidationEvidence {
|
|
179
|
+
file?: string;
|
|
180
|
+
line?: number;
|
|
181
|
+
snippet?: string;
|
|
182
|
+
command?: string;
|
|
183
|
+
details?: Record<string, unknown>;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export interface ValidationResult {
|
|
187
|
+
ruleId: string;
|
|
188
|
+
standardId: string;
|
|
189
|
+
title: string;
|
|
190
|
+
status: 'PASS' | 'WARN' | 'FAIL' | 'SKIPPED';
|
|
191
|
+
severity: 'critical' | 'high' | 'medium' | 'low' | 'info';
|
|
192
|
+
message: string;
|
|
193
|
+
evidence?: ValidationEvidence;
|
|
194
|
+
remediation?: string;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export type ValidatorFn = (context: ValidatorContext) => Promise<ValidationResult[]>;
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
#### Initial Executable Validators
|
|
201
|
+
1. **The Undo Kit & Deployment Safety:**
|
|
202
|
+
- `deployment.rollback-plan`: Verifies presence and contents of `ROLLBACK.md` (documents hosting rollback, database backup commands, feature flags, rehearsal record).
|
|
203
|
+
- `deployment.last-good-deploy`: Validates deployment hosting documentation (Vercel, Netlify, Docker, etc.).
|
|
204
|
+
- `deployment.backup-first`: Validates backup commands and prevents deployment without backup step.
|
|
205
|
+
- `deployment.feature-flags`: Detects feature switches/flags configuration in code or database schema.
|
|
206
|
+
2. **Database Migration Safety (Expand-and-Contract):**
|
|
207
|
+
- `database.expand-and-contract`: Scans pending/recent SQL migrations and Prisma schemas for destructive operations (`DROP TABLE`, `DROP COLUMN`, `TRUNCATE`, `ALTER TABLE ... RENAME`). Flags them as FAIL or WARN, requiring expand-and-contract two-phase evolution.
|
|
208
|
+
3. **Security Standards:**
|
|
209
|
+
- `security.secret-detection`: Deep scan for exposed API keys, private keys, and high-entropy credentials.
|
|
210
|
+
- `security.dependency-audit`: Evaluates production dependencies for known critical vulnerabilities.
|
|
211
|
+
- `security.sensitive-files`: Verifies credential files (`.env`, `.env.production`) are in `.gitignore`.
|
|
212
|
+
4. **Testing Contracts:**
|
|
213
|
+
- `testing.test-availability`: Validates presence of unit/integration test suites.
|
|
214
|
+
- `testing.contract-verification`: Validates `commands.json` testing contract is non-vacuous.
|
|
215
|
+
5. **Code Quality:**
|
|
216
|
+
- `code-quality.typecheck`: Strict TypeScript typechecking verification.
|
|
217
|
+
- `code-quality.lint`: Verification that linter runs without errors.
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
### 2.5 The Undo Kit Standard (`deployment-safety-and-rollback`)
|
|
222
|
+
Directly implements the 4 mechanisms from the canonical specification:
|
|
223
|
+
- **Button 1 (Last Good Deploy):** Instant rollback procedure documentation for Vercel, Netlify, Docker, or Cloudflare.
|
|
224
|
+
- **Button 2 (Backup First):** Pre-release database backup requirement, dump commands (`supabase db dump`, `pg_dump`, etc.), restore command into isolated test projects.
|
|
225
|
+
- **Button 3 (A Switch):** Feature flags table (`feature_flags` with `name` and `enabled`) or environment toggle, defaulting new features to `enabled = false`.
|
|
226
|
+
- **Button 4 (Try It Once / Recovery Rehearsal):** Rehearsal log in `ROLLBACK.md` recording actual rollback time, restore time, and switch verification.
|
|
227
|
+
- **Expand-and-Contract Rule:** Additive changes only in release $N$; removals deferred to release $N+1$.
|
|
228
|
+
- **Destructive Operation Blocking:** Blocks automatic execution of `DROP`, `TRUNCATE`, database reset, or force-push.
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
### 2.6 Configuration Inheritance & Documented Exceptions
|
|
233
|
+
Stored in `.devworkspace/standards/config.json`:
|
|
234
|
+
|
|
235
|
+
```json
|
|
236
|
+
{
|
|
237
|
+
"version": "1.0.0",
|
|
238
|
+
"autoDetect": true,
|
|
239
|
+
"enforcement": {
|
|
240
|
+
"security": "required",
|
|
241
|
+
"database": "required",
|
|
242
|
+
"deployment": "required",
|
|
243
|
+
"testing": "required",
|
|
244
|
+
"code-quality": "recommended",
|
|
245
|
+
"architecture": "recommended"
|
|
246
|
+
},
|
|
247
|
+
"disabledStandards": [],
|
|
248
|
+
"exceptions": [
|
|
249
|
+
{
|
|
250
|
+
"ruleId": "database.expand-and-contract",
|
|
251
|
+
"reason": "Initial greenfield project initialization before production deployment",
|
|
252
|
+
"approvedBy": "Lead Architect",
|
|
253
|
+
"approvedAt": "2026-11-30T10:00:00Z",
|
|
254
|
+
"expiresAt": "2026-12-31T23:59:59Z"
|
|
255
|
+
}
|
|
256
|
+
]
|
|
257
|
+
}
|
|
258
|
+
```
|
|
259
|
+
**Security Non-Bypassable Rule:** Critical global security rules (`security.secret-detection`, `security.dependency-audit`) cannot be bypassed by simple disable flags; they require a fully documented exception with justification, approver, and expiration date.
|
|
260
|
+
|
|
261
|
+
---
|
|
262
|
+
|
|
263
|
+
### 2.7 Knowledge Acquisition Workflow (`devworkspace standards add`)
|
|
264
|
+
Provides a structured, offline ingestion pipeline:
|
|
265
|
+
1. `devworkspace standards add <file>` accepts Markdown or JSON standard definitions.
|
|
266
|
+
2. Parses frontmatter or metadata.
|
|
267
|
+
3. Validates against `EngineeringStandard` schema.
|
|
268
|
+
4. Checks for duplicate standard IDs or conflicting requirements.
|
|
269
|
+
5. Saves with status `DRAFT` or `REVIEW`.
|
|
270
|
+
6. Generates recommendations for executable validator rules.
|
|
271
|
+
7. Promotes to `APPROVED` only upon maintainer review (`devworkspace standards approve <id>`).
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
### 2.8 CLI Integration & Command Surface
|
|
276
|
+
|
|
277
|
+
Integrated directly into `devworkspace` CLI:
|
|
278
|
+
- `devworkspace standards list`: Lists all available standards with status, category, and applicability.
|
|
279
|
+
- `devworkspace standards show <id>`: Displays full requirements, guidelines, rules, and validators.
|
|
280
|
+
- `devworkspace standards audit`: Determines applicable standards and checks current project compliance.
|
|
281
|
+
- `devworkspace standards check`: Executes all applicable validators and returns PASS/WARN/FAIL findings.
|
|
282
|
+
- `devworkspace standards apply <id>`: Applies standard rules, creates required templates (e.g. `ROLLBACK.md`), updates configuration.
|
|
283
|
+
- `devworkspace standards add <path>`: Imports a new standard into the local/global library.
|
|
284
|
+
- `devworkspace standards update`: Synchronizes approved global standards and updates registry cache.
|
|
285
|
+
- `devworkspace standards report [--out <path>]`: Emits comprehensive compliance audit report in Markdown or JSON.
|
|
286
|
+
- `devworkspace standards validate`: Validates internal registry consistency and rule linkage.
|
|
287
|
+
- All commands support `--json`, `--quiet`, `--verbose`, and strict exit codes for CI/CD integration.
|