@cassiomc1/forgeloop 2.0.0-rc.5 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.cursor/rules/project-loop.mdc +1 -1
- package/.github/copilot-instructions.md +1 -1
- package/AGENTS.md +1 -1
- package/CLAUDE.md +1 -1
- package/CONTRIBUTING.md +3 -1
- package/DOCS_INDEX.md +2 -0
- package/ENG/accessibility-eng.md +6 -6
- package/ENG/clean-code-eng.md +2 -2
- package/ENG/design-code-eng.md +17 -15
- package/ENG/documentation-quality-eng.md +10 -2
- package/ENG/dotnet-aspnetcore-development-eng.md +8 -4
- package/ENG/flutter-development-eng.md +38 -59
- package/ENG/games-code-design-web-eng.md +2 -2
- package/ENG/nodejs-backend-development-eng.md +7 -4
- package/ENG/perf-code-eng.md +3 -3
- package/ENG/php-development-eng.md +2 -2
- package/ENG/premium-sites-studio-eng.md +9 -2
- package/ENG/python-development-eng.md +7 -1
- package/ENG/rust-development-eng.md +22 -32
- package/ENG/sec-code-eng.md +19 -3
- package/ENG/sql-development-eng.md +5 -4
- package/ENG/taste-frontend-eng.md +125 -4
- package/ENG/test-code-eng.md +2 -2
- package/GUIDE_ROUTER.md +18 -4
- package/PROTOCOL_INTEGRATION.md +21 -0
- package/README.md +15 -13
- package/THIRD_PARTY_NOTICES.md +60 -6
- package/docs/AGENT_PROTOCOL_SUMMARY.md +1 -1
- package/docs/AGENT_SKILL.md +16 -0
- package/docs/DOCUMENTATION_GUIDE.md +6 -0
- package/docs/FORGELOOP_AUDIT.md +1 -1
- package/docs/GETTING_STARTED.md +8 -1
- package/docs/GUIDE_MAINTENANCE.md +106 -0
- package/docs/PACKAGE_CONTENTS.md +22 -5
- package/docs/RELEASE_CHECKLIST.md +68 -35
- package/docs/REVENUE_CENTRIC_DESIGN.md +69 -0
- package/docs/SECURITY_AUDIT_SKILL.md +131 -0
- package/docs/SECURITY_REVIEW.md +6 -0
- package/docs/STABLE_2_ACCEPTANCE.md +127 -0
- package/docs/TROUBLESHOOTING.md +171 -0
- package/docs/documentation-manifest.json +244 -0
- package/package.json +12 -7
- package/scripts/generate-forgeloop-skill.mjs +8 -0
- package/scripts/verify-revenue-design-skill.mjs +37 -0
- package/scripts/verify-security-audit-skill.mjs +68 -0
- package/skills/forgeloop/SKILL.md +8 -0
- package/skills/forgeloop/references/revenue-centric-design/LICENSE +30 -0
- package/skills/forgeloop/references/revenue-centric-design/PIN.json +14 -0
- package/skills/forgeloop/references/revenue-centric-design/SKILL.md +64 -0
- package/skills/forgeloop/references/revenue-centric-design/references/playbook.md +36 -0
- package/skills/security-audit/AI-AND-LLM.md +83 -0
- package/skills/security-audit/ATTACK-CLASSES.md +130 -0
- package/skills/security-audit/CLIENT-SIDE.md +83 -0
- package/skills/security-audit/CLOUD-AND-DEPLOYMENT.md +86 -0
- package/skills/security-audit/DATA-ISOLATION-AND-LIFECYCLE.md +84 -0
- package/skills/security-audit/DESKTOP-MOBILE-AND-LOCAL-IPC.md +89 -0
- package/skills/security-audit/HUNTING.md +251 -0
- package/skills/security-audit/LICENSE +21 -0
- package/skills/security-audit/MEMORY-SAFETY-AND-BINARY.md +101 -0
- package/skills/security-audit/PIN.json +30 -0
- package/skills/security-audit/PROTOCOLS-RPC-AND-MESSAGING.md +81 -0
- package/skills/security-audit/RECONNAISSANCE.md +156 -0
- package/skills/security-audit/RESOURCE-EXHAUSTION-AND-AVAILABILITY.md +78 -0
- package/skills/security-audit/SKILL.md +192 -0
- package/skills/security-audit/SUPPLY-CHAIN-AND-RELEASE.md +73 -0
- package/skills/security-audit/VALIDATION-AND-REPORTING.md +186 -0
- package/skills/security-audit/WEB-PROTOCOL-AND-AUTH.md +105 -0
- package/skills/security-audit/report-schema.json +461 -0
- package/skills/security-audit/validate-coverage-ledger.cjs +872 -0
- package/skills/security-audit/validate-coverage-ledger.test.cjs +740 -0
- package/skills/security-audit/validate-findings.cjs +773 -0
- package/skills/security-audit/validate-findings.test.cjs +652 -0
- package/src/core/completion-artifacts.js +4 -7
- package/src/core/diagnosis.js +3 -5
- package/src/core/diagnostic-record.js +4 -4
- package/src/core/error-codes.js +180 -2
- package/src/core/next-action-recovery-phases.js +3 -0
- package/src/core/next-action-review-correction.js +26 -0
- package/src/core/next-action-review-phase.js +25 -15
- package/src/core/parsers/dotnet-project.js +221 -0
- package/src/core/parsers/limits.js +9 -0
- package/src/core/parsers/pubspec.js +307 -0
- package/src/core/parsers/shared.js +4 -0
- package/src/core/project-detection.js +6 -527
- package/src/core/reconcile-closure.js +5 -0
- package/src/core/review-correction.js +51 -0
- package/src/storage/capabilities.js +1 -1
package/src/core/diagnosis.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { appendProtocolEvent, validateEventLedger } from "./events.js";
|
|
2
2
|
import { readWorkState, mutateWorkState } from "./work-state.js";
|
|
3
3
|
import { getTaskTransaction, withTaskTransaction } from "./transaction.js";
|
|
4
|
+
import { assertDiagnosisPhase, assertReviewChronology } from "./review-correction.js";
|
|
4
5
|
import {
|
|
5
6
|
DIAGNOSIS_INFORMATION_GAIN,
|
|
6
7
|
assertDiagnosisDetails,
|
|
@@ -49,11 +50,7 @@ async function recordDiagnosisInTransaction({
|
|
|
49
50
|
error.code = "E_STATE_MISSING";
|
|
50
51
|
throw error;
|
|
51
52
|
}
|
|
52
|
-
|
|
53
|
-
const error = new Error(`Recording a diagnosis requires phase DIAGNOSING, currently ${state.phase}`);
|
|
54
|
-
error.code = "E_PHASE_PREREQUISITE_MISSING";
|
|
55
|
-
throw error;
|
|
56
|
-
}
|
|
53
|
+
assertDiagnosisPhase(state);
|
|
57
54
|
if (typeof state.verificationCycle !== "number" || state.verificationCycle < 1) {
|
|
58
55
|
const error = new Error("Active verification cycle must be an integer >= 1");
|
|
59
56
|
error.code = "E_DIAGNOSIS_INVALID";
|
|
@@ -67,6 +64,7 @@ async function recordDiagnosisInTransaction({
|
|
|
67
64
|
error.code = first.code;
|
|
68
65
|
throw error;
|
|
69
66
|
}
|
|
67
|
+
assertReviewChronology(state, ledger.events);
|
|
70
68
|
|
|
71
69
|
const verificationStarted = ledger.events.some(
|
|
72
70
|
(e) => e.taskId === state.taskId && e.event === "VERIFICATION_STARTED",
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
interventionSemanticFingerprint,
|
|
12
12
|
} from "./diagnostic-model.js";
|
|
13
13
|
import { projectHypothesisStates, getHypothesisState } from "./hypothesis-projection.js";
|
|
14
|
+
import { assertDiagnosisPhase, assertReviewChronology, requiresFailureBinding } from "./review-correction.js";
|
|
14
15
|
|
|
15
16
|
const TERMINAL_STATUSES = Object.freeze(["FALSIFIED", "SUPERSEDED", "UNRESOLVED"]);
|
|
16
17
|
|
|
@@ -112,10 +113,9 @@ async function recordDiagnosticCase({
|
|
|
112
113
|
}
|
|
113
114
|
|
|
114
115
|
const state = await requireActiveState(target, { packageRoot, taskId });
|
|
115
|
-
|
|
116
|
-
throw stateError("E_PHASE_PREREQUISITE_MISSING", `Recording a structured diagnostic case requires phase DIAGNOSING, currently ${state.phase}`);
|
|
117
|
-
}
|
|
116
|
+
assertDiagnosisPhase(state);
|
|
118
117
|
const ledger = await requireValidLedger(target, packageRoot, taskId);
|
|
118
|
+
assertReviewChronology(state, ledger.events);
|
|
119
119
|
|
|
120
120
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
121
121
|
throw stateError("E_DIAGNOSTIC_CASE_INVALID", "diagnostic case must be a JSON object");
|
|
@@ -156,7 +156,7 @@ async function recordDiagnosticCase({
|
|
|
156
156
|
|
|
157
157
|
// A VERIFICATION_FAILURE case must bind to failed/blocked evidence from the
|
|
158
158
|
// active correction cycle so it cannot be formally valid yet semantically empty.
|
|
159
|
-
if (parsed.failureClass
|
|
159
|
+
if (requiresFailureBinding(state, parsed.failureClass)) {
|
|
160
160
|
const bindsToFailure = [
|
|
161
161
|
...parsed.hypotheses.flatMap((hypothesis) => hypothesis.evidenceRefs ?? []),
|
|
162
162
|
...(parsed.observations ?? [])
|
package/src/core/error-codes.js
CHANGED
|
@@ -1526,6 +1526,175 @@ export const E_BASELINE_RECORD_DURING_ACTIVE_TASK = "E_BASELINE_RECORD_DURING_AC
|
|
|
1526
1526
|
export const E_POLICY_INITIALIZATION_FAILED = "E_POLICY_INITIALIZATION_FAILED";
|
|
1527
1527
|
export const E_INIT_KIT_CONFLICT = "E_INIT_KIT_CONFLICT";
|
|
1528
1528
|
|
|
1529
|
+
/**
|
|
1530
|
+
* Codes emitted by runtime modules that do not yet have curated metadata.
|
|
1531
|
+
* They are published so integrators can recognise every code ForgeLoop can
|
|
1532
|
+
* return, but they carry no stable compatibility promise until promoted into
|
|
1533
|
+
* PUBLIC_ERROR_CODES. tests/error-registry-coverage.test.js keeps this list in
|
|
1534
|
+
* sync with the codes emitted under src/.
|
|
1535
|
+
*/
|
|
1536
|
+
export const EMITTED_UNCLASSIFIED_ERROR_CODES = Object.freeze([
|
|
1537
|
+
"E_ACTION_AUTHORIZATION_REQUIRED",
|
|
1538
|
+
"E_ACTION_CAPABILITY_INVALID",
|
|
1539
|
+
"E_AUDIT_UX_INPUT_INVALID",
|
|
1540
|
+
"E_AUDIT_UX_INVALID_ERROR",
|
|
1541
|
+
"E_AUDIT_UX_OUTPUT_LIMIT",
|
|
1542
|
+
"E_BENCHMARK_INVALID",
|
|
1543
|
+
"E_BUNDLE_DIGEST_INVALID",
|
|
1544
|
+
"E_BUNDLE_PATH_INVALID",
|
|
1545
|
+
"E_BUNDLE_TASK_MISMATCH",
|
|
1546
|
+
"E_CHECK_BLOCKED",
|
|
1547
|
+
"E_CHECK_EXECUTION_PROVENANCE_MISSING",
|
|
1548
|
+
"E_CHECK_FAILED",
|
|
1549
|
+
"E_CHECK_REQUIRED",
|
|
1550
|
+
"E_COMMAND_EXECUTION_FAILED",
|
|
1551
|
+
"E_COMMAND_PROVENANCE_UNATTESTED",
|
|
1552
|
+
"E_COMMAND_UNSUPPORTED",
|
|
1553
|
+
"E_CONFIG_INVALID",
|
|
1554
|
+
"E_CONTINUITY_INCONSISTENT",
|
|
1555
|
+
"E_CONTRACT_INPUT_CONFLICT",
|
|
1556
|
+
"E_CONTRACT_PRESET_UNKNOWN",
|
|
1557
|
+
"E_CONTRACT_PROFILE_STRICT_UNVERIFIED",
|
|
1558
|
+
"E_CONTRACT_REVISION_UNSAFE",
|
|
1559
|
+
"E_CYCLE_CLOSED",
|
|
1560
|
+
"E_DECISION_BINDING_INVALID",
|
|
1561
|
+
"E_DECISION_IMMUTABLE",
|
|
1562
|
+
"E_DECISION_LEDGER_INVALID",
|
|
1563
|
+
"E_DISCOVERY_REQUIRED",
|
|
1564
|
+
"E_DUPLICATE_PROFILE_SOURCE",
|
|
1565
|
+
"E_EMULATED_SERVICES_CANCELLED",
|
|
1566
|
+
"E_EMULATED_SERVICES_CLEANUP_FAILED",
|
|
1567
|
+
"E_EMULATED_SERVICES_CONFIG_INVALID",
|
|
1568
|
+
"E_EMULATED_SERVICES_ENDPOINT_INVALID",
|
|
1569
|
+
"E_EMULATED_SERVICES_EXECUTION_FAILED",
|
|
1570
|
+
"E_EMULATED_SERVICES_OUTPUT_INVALID",
|
|
1571
|
+
"E_EMULATED_SERVICES_OUTPUT_LIMIT",
|
|
1572
|
+
"E_EMULATED_SERVICES_TIMEOUT",
|
|
1573
|
+
"E_EMULATED_SERVICES_UNAVAILABLE",
|
|
1574
|
+
"E_EMULATED_SERVICES_VERSION_UNSUPPORTED",
|
|
1575
|
+
"E_EVENT_INVALID",
|
|
1576
|
+
"E_EVIDENCE_BLOCKED",
|
|
1577
|
+
"E_EVIDENCE_MISSING",
|
|
1578
|
+
"E_EXECUTION_INVALID",
|
|
1579
|
+
"E_EXECUTION_PROFILE_CONTEXT_INVALID",
|
|
1580
|
+
"E_GATE_REVALIDATION_ACK_REQUIRED",
|
|
1581
|
+
"E_GATE_REVALIDATION_INVALID",
|
|
1582
|
+
"E_GATE_REVALIDATION_NOT_STALE",
|
|
1583
|
+
"E_GATE_REVALIDATION_PHASE_INVALID",
|
|
1584
|
+
"E_GATE_REVALIDATION_UNSAFE",
|
|
1585
|
+
"E_GATE_TASK_MISMATCH",
|
|
1586
|
+
"E_HIDDEN_KIT_MIGRATION_CONFLICT",
|
|
1587
|
+
"E_INITIAL_LIFECYCLE_INVALID",
|
|
1588
|
+
"E_INPUT_CONFLICT",
|
|
1589
|
+
"E_INSTALLATION_INVALID",
|
|
1590
|
+
"E_INTEGRATION_RESOURCE_UNKNOWN",
|
|
1591
|
+
"E_LEDGER_HASH_INVALID",
|
|
1592
|
+
"E_LEDGER_INVALID",
|
|
1593
|
+
"E_LEDGER_RELATION_INVALID",
|
|
1594
|
+
"E_LEDGER_SOURCE_INVALID",
|
|
1595
|
+
"E_LEDGER_STALE",
|
|
1596
|
+
"E_LEGACY_FILE_MIGRATION_CONFLICT",
|
|
1597
|
+
"E_MODEL_ROUTE_SAFETY_FLOOR_INVALID",
|
|
1598
|
+
"E_NATIVE_ADAPTER_MIGRATION_CONFLICT",
|
|
1599
|
+
"E_NEXT_ACTION_BLOCKED",
|
|
1600
|
+
"E_NO_INFORMATION_GAIN",
|
|
1601
|
+
"E_PHASE_ARTIFACT_STALE",
|
|
1602
|
+
"E_PHASE_EVIDENCE_MISSING",
|
|
1603
|
+
"E_PHASE_UNKNOWN",
|
|
1604
|
+
"E_PHASE_UNSUPPORTED",
|
|
1605
|
+
"E_POLICY_UNKNOWN",
|
|
1606
|
+
"E_PREFLIGHT_CONTRACT_STALE",
|
|
1607
|
+
"E_PREFLIGHT_READY_INCONSISTENT",
|
|
1608
|
+
"E_PREFLIGHT_ROUTE_STALE",
|
|
1609
|
+
"E_PREFLIGHT_TASK_MISMATCH",
|
|
1610
|
+
"E_PRODUCTION_READINESS_REQUIREMENT_PENDING",
|
|
1611
|
+
"E_PROFILE_MIGRATION_CONFLICT",
|
|
1612
|
+
"E_PROFILE_SOURCE_INVALID",
|
|
1613
|
+
"E_PROVIDER_AUTHORITY_ESCALATION",
|
|
1614
|
+
"E_PROVIDER_CAPABILITY_UNSUPPORTED",
|
|
1615
|
+
"E_PROVIDER_EXECUTION_FAILED",
|
|
1616
|
+
"E_PROVIDER_INVALID",
|
|
1617
|
+
"E_PROVIDER_OUTPUT_INVALID",
|
|
1618
|
+
"E_PROVIDER_OUTPUT_LIMIT",
|
|
1619
|
+
"E_PROVIDER_TIMEOUT",
|
|
1620
|
+
"E_PROVIDER_UNAVAILABLE",
|
|
1621
|
+
"E_REPOSITORY_GIT_COMMAND_FAILED",
|
|
1622
|
+
"E_REQUIRED_ARTIFACT_STALE",
|
|
1623
|
+
"E_REQUIREMENT_UNMET",
|
|
1624
|
+
"E_REVIEW_FINDING_REQUIRED",
|
|
1625
|
+
"E_ROUTE_PHASE_UNSUPPORTED",
|
|
1626
|
+
"E_STATE_INVALID",
|
|
1627
|
+
"E_STATE_LEDGER_MISMATCH",
|
|
1628
|
+
"E_STATE_REVISION_CONFLICT",
|
|
1629
|
+
"E_STATE_UNREADABLE",
|
|
1630
|
+
"E_STORAGE_ARTIFACT_BYTES_UNAVAILABLE",
|
|
1631
|
+
"E_STORAGE_ARTIFACT_INVALID",
|
|
1632
|
+
"E_STORAGE_ASYNC_TRANSACTION",
|
|
1633
|
+
"E_STORAGE_ATTACHMENT_INVALID",
|
|
1634
|
+
"E_STORAGE_BACKUP_INVALID",
|
|
1635
|
+
"E_STORAGE_BUSY",
|
|
1636
|
+
"E_STORAGE_CATALOG_CHANGED",
|
|
1637
|
+
"E_STORAGE_CONFIGURATION_INVALID",
|
|
1638
|
+
"E_STORAGE_CORRUPT",
|
|
1639
|
+
"E_STORAGE_EXPORT_DESTINATION",
|
|
1640
|
+
"E_STORAGE_EXPORT_IDENTITY",
|
|
1641
|
+
"E_STORAGE_EXPORT_UNSUPPORTED",
|
|
1642
|
+
"E_STORAGE_FULL",
|
|
1643
|
+
"E_STORAGE_IMPORT_ABORTED",
|
|
1644
|
+
"E_STORAGE_IMPORT_DESTINATION_EXISTS",
|
|
1645
|
+
"E_STORAGE_IMPORT_FAILED",
|
|
1646
|
+
"E_STORAGE_IMPORT_IDENTITY_COLLISION",
|
|
1647
|
+
"E_STORAGE_IMPORT_NAMESPACE_INVALID",
|
|
1648
|
+
"E_STORAGE_IMPORT_SIGNATURE_UNMAPPED",
|
|
1649
|
+
"E_STORAGE_IMPORT_SINGLETON_UNSUPPORTED",
|
|
1650
|
+
"E_STORAGE_INTEGRITY_INVALID",
|
|
1651
|
+
"E_STORAGE_INTERRUPTED",
|
|
1652
|
+
"E_STORAGE_MAINTENANCE_IN_PROGRESS",
|
|
1653
|
+
"E_STORAGE_MAINTENANCE_OWNER_INVALID",
|
|
1654
|
+
"E_STORAGE_METADATA_INVALID",
|
|
1655
|
+
"E_STORAGE_MIGRATION_ACTIVATION_INVALID",
|
|
1656
|
+
"E_STORAGE_MIGRATION_ARCHIVE_INVALID",
|
|
1657
|
+
"E_STORAGE_MIGRATION_BUSY",
|
|
1658
|
+
"E_STORAGE_MIGRATION_CAPTURE_INVALID",
|
|
1659
|
+
"E_STORAGE_MIGRATION_DESTINATION_INVALID",
|
|
1660
|
+
"E_STORAGE_MIGRATION_PARITY_INVALID",
|
|
1661
|
+
"E_STORAGE_MIGRATION_PUBLICATION_INVALID",
|
|
1662
|
+
"E_STORAGE_MIGRATION_QUIESCENCE_REQUIRED",
|
|
1663
|
+
"E_STORAGE_MIGRATION_REQUIRED",
|
|
1664
|
+
"E_STORAGE_MIGRATION_SOURCE_CHANGED",
|
|
1665
|
+
"E_STORAGE_MIGRATION_SOURCE_INVALID",
|
|
1666
|
+
"E_STORAGE_MIGRATION_TERMINAL_INVALID",
|
|
1667
|
+
"E_STORAGE_MIGRATION_UNMAPPED_SOURCE",
|
|
1668
|
+
"E_STORAGE_MIGRATION_VALIDATION_FAILED",
|
|
1669
|
+
"E_STORAGE_OBSERVATION_INCOMPLETE",
|
|
1670
|
+
"E_STORAGE_OPERATION_UNSUPPORTED",
|
|
1671
|
+
"E_STORAGE_PAYLOAD_MISMATCH",
|
|
1672
|
+
"E_STORAGE_READ_ONLY",
|
|
1673
|
+
"E_STORAGE_RESTORE_INVALID",
|
|
1674
|
+
"E_STORAGE_RUNTIME_CLOSED",
|
|
1675
|
+
"E_STORAGE_RUNTIME_CONFIGURATION_INVALID",
|
|
1676
|
+
"E_STORAGE_SNAPSHOT_TRANSACTION",
|
|
1677
|
+
"E_STORAGE_SOURCE_ROLLBACK_INVALID",
|
|
1678
|
+
"E_STORAGE_SOURCE_ROLLBACK_VALIDATION_INVALID",
|
|
1679
|
+
"E_STORAGE_TOPOLOGY_UNSUPPORTED",
|
|
1680
|
+
"E_STORAGE_TRANSACTION_EXPIRED",
|
|
1681
|
+
"E_STORAGE_TRANSACTION_INVALID",
|
|
1682
|
+
"E_STORAGE_TRANSACTION_LEAKED",
|
|
1683
|
+
"E_STORAGE_UNSUPPORTED_RUNTIME",
|
|
1684
|
+
"E_STORAGE_VERSION_MARKER_INVALID",
|
|
1685
|
+
"E_STORAGE_VERSION_UNSUPPORTED",
|
|
1686
|
+
"E_TARGET_REQUIRED",
|
|
1687
|
+
"E_TASK_CLAIM_CONFLICT",
|
|
1688
|
+
"E_TASK_ID_MISMATCH",
|
|
1689
|
+
"E_TASK_LOCK_STATE_UNKNOWN",
|
|
1690
|
+
"E_TASK_PHASE_INVALID",
|
|
1691
|
+
"E_TEST_ID_UNKNOWN",
|
|
1692
|
+
"E_TEST_PRUNE_BLOCKED",
|
|
1693
|
+
"E_TRANSACTION_INCOMPLETE",
|
|
1694
|
+
"E_UNRESOLVED_DECISION",
|
|
1695
|
+
"E_VERIFICATION_CHECK_REQUIRED",
|
|
1696
|
+
]);
|
|
1697
|
+
|
|
1529
1698
|
export const ALL_KNOWN_ERROR_CODES = Object.freeze(new Set([
|
|
1530
1699
|
...FAILURE_CODES,
|
|
1531
1700
|
E_VERIFICATION_TOOL_UNAVAILABLE,
|
|
@@ -1791,20 +1960,29 @@ export const ALL_KNOWN_ERROR_CODES = Object.freeze(new Set([
|
|
|
1791
1960
|
E_HANDOFF_STALE,
|
|
1792
1961
|
E_HANDOFF_ALREADY_ACCEPTED,
|
|
1793
1962
|
E_HANDOFF_ACCEPTANCE_INCONSISTENT,
|
|
1963
|
+
...EMITTED_UNCLASSIFIED_ERROR_CODES,
|
|
1794
1964
|
]));
|
|
1795
1965
|
|
|
1966
|
+
const UNCLASSIFIED_ERROR_CODES = new Set(EMITTED_UNCLASSIFIED_ERROR_CODES);
|
|
1967
|
+
|
|
1796
1968
|
/**
|
|
1797
1969
|
* Complete public registry. Older callers can retain PUBLIC_ERROR_CODES while
|
|
1798
1970
|
* documentation and compatibility handshakes enumerate every stable code.
|
|
1799
1971
|
*/
|
|
1800
1972
|
export const PUBLIC_ERROR_REGISTRY = Object.freeze(
|
|
1801
1973
|
Object.fromEntries([...ALL_KNOWN_ERROR_CODES].sort().map((code) => [code, Object.freeze(
|
|
1802
|
-
PUBLIC_ERROR_CODES[code] ?? {
|
|
1974
|
+
PUBLIC_ERROR_CODES[code] ?? (UNCLASSIFIED_ERROR_CODES.has(code) ? {
|
|
1975
|
+
code,
|
|
1976
|
+
category: "protocol",
|
|
1977
|
+
classification: "PUBLIC_UNCLASSIFIED",
|
|
1978
|
+
meaning: "Emitted by ForgeLoop but not yet curated; the code name is the contract and it carries no stable compatibility promise.",
|
|
1979
|
+
safeResolution: "Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json.",
|
|
1980
|
+
} : {
|
|
1803
1981
|
code,
|
|
1804
1982
|
category: "protocol",
|
|
1805
1983
|
classification: "PUBLIC_STABLE",
|
|
1806
1984
|
meaning: "A ForgeLoop protocol validation or lifecycle condition was not satisfied.",
|
|
1807
1985
|
safeResolution: "Inspect the structured command result, correct the named artifact or prerequisite, then run forgeloop next --json.",
|
|
1808
|
-
},
|
|
1986
|
+
}),
|
|
1809
1987
|
)])),
|
|
1810
1988
|
);
|
|
@@ -4,6 +4,7 @@ import { artifactError } from "./next-action-artifacts.js";
|
|
|
4
4
|
import { resolveCurrentCycleDiagnostic } from "./diagnostic-projection.js";
|
|
5
5
|
import { buildTaskReflection } from "./reflection.js";
|
|
6
6
|
import { evaluateProgress, PROGRESS_STATUS } from "./progress.js";
|
|
7
|
+
import { reviewCorrectionAction } from "./next-action-review-correction.js";
|
|
7
8
|
|
|
8
9
|
export async function resolveDiagnosingPhase({ target, packageRoot, normalized, state, context, eventsRel, requiredArtifacts, stateRel }) {
|
|
9
10
|
const ledger = await validateEventLedger(target, packageRoot, { taskId: normalized.taskId ?? null });
|
|
@@ -65,6 +66,8 @@ export async function resolveDiagnosingPhase({ target, packageRoot, normalized,
|
|
|
65
66
|
}
|
|
66
67
|
|
|
67
68
|
export async function resolveCorrectingPhase({ target, packageRoot, normalized, state, context, requiredArtifacts }) {
|
|
69
|
+
const correction = await reviewCorrectionAction({ target, packageRoot, taskId: normalized.taskId ?? null, state, context, requiredArtifacts });
|
|
70
|
+
if (correction) return correction;
|
|
68
71
|
const ledgerForCorrection = await validateEventLedger(target, packageRoot, { taskId: normalized.taskId ?? null });
|
|
69
72
|
const correctionCycle = state.verificationCycle ?? 1;
|
|
70
73
|
const hasStructuredCase = ledgerForCorrection.events.some(
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { validateEventLedger } from "./events.js";
|
|
2
|
+
import { resolveCurrentCycleDiagnostic } from "./diagnostic-projection.js";
|
|
3
|
+
import { hasCurrentReview, reviewFailures } from "./review-correction.js";
|
|
4
|
+
import { NEXT_ACTIONS, decision, recordCheckCommandSpec, recordDiagnosisCommandSpec, result } from "./next-action-model.js";
|
|
5
|
+
import { artifactError } from "./next-action-artifacts.js";
|
|
6
|
+
|
|
7
|
+
export async function reviewCorrectionAction({ target, packageRoot, taskId, state, context, requiredArtifacts }) {
|
|
8
|
+
const failures = reviewFailures(state);
|
|
9
|
+
if (state.phase === "REVIEWING" && failures.length === 0) return null;
|
|
10
|
+
const ledger = await validateEventLedger(target, packageRoot, { taskId });
|
|
11
|
+
if (!ledger.valid || !hasCurrentReview(state, ledger.events)) return null;
|
|
12
|
+
if (failures.length === 0) {
|
|
13
|
+
return result({ ...context, nextAction: NEXT_ACTIONS.RECORD_VERIFICATION,
|
|
14
|
+
reasons: [artifactError("E_REVIEW_FINDING_REQUIRED", "Record an observed failed or blocked review finding before diagnosis or retry")],
|
|
15
|
+
commandSpecs: [recordCheckCommandSpec("<reviewed requirement>")], requiredArtifacts });
|
|
16
|
+
}
|
|
17
|
+
const diagnosis = resolveCurrentCycleDiagnostic(ledger.events, state.taskId, state.verificationCycle);
|
|
18
|
+
if (!diagnosis) {
|
|
19
|
+
return result({ ...context, nextAction: NEXT_ACTIONS.RECORD_DIAGNOSIS,
|
|
20
|
+
reasons: [artifactError("E_DIAGNOSIS_REQUIRED", "Diagnose the failed review finding using evidence from the current verification cycle")],
|
|
21
|
+
commandSpecs: [recordDiagnosisCommandSpec()], requiredArtifacts });
|
|
22
|
+
}
|
|
23
|
+
return state.phase === "REVIEWING"
|
|
24
|
+
? decision(context, NEXT_ACTIONS.CORRECT, artifactError("PHASE_REVIEWING", "The diagnosed review finding requires correction"))
|
|
25
|
+
: null;
|
|
26
|
+
}
|
|
@@ -6,17 +6,31 @@ import { evaluateRequiredEvidence, classifyRequirement, terminalRequirementsForC
|
|
|
6
6
|
import { validateEventLedger, validateCompletionRecoveryAuthorization } from "./events.js";
|
|
7
7
|
import { NEXT_ACTIONS, commandFor, decision, recordTerminalResultCommandSpec, result } from "./next-action-model.js";
|
|
8
8
|
import { artifactError, checkListReasons, loadArtifact, requirementsAndCoverage } from "./next-action-artifacts.js";
|
|
9
|
+
import { reviewCorrectionAction } from "./next-action-review-correction.js";
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
|
|
12
|
+
// Only an absent receipt is an expected recovery input; corrupt or unreadable
|
|
13
|
+
// storage propagates so the caller fails closed.
|
|
14
|
+
async function readRecoveryReceipt(target, receiptRel, packageRoot) {
|
|
15
|
+
try {
|
|
16
|
+
const receiptArtifact = await readJsonArtifact(target, receiptRel, "execution-receipt", packageRoot);
|
|
17
|
+
return receiptArtifact?.value ?? null;
|
|
18
|
+
} catch (error) {
|
|
19
|
+
if (error?.code !== "ARTIFACT_MISSING") throw error;
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export async function resolveReviewingPhase(options) {
|
|
25
|
+
const { target, packageRoot, explicitTaskId, state, context, requiredArtifacts } = options;
|
|
26
|
+
const invalidChecks = checkListReasons(state);
|
|
27
|
+
if (invalidChecks.length > 0) return result({ ...context, nextAction: NEXT_ACTIONS.RESOLVE_BLOCKER, reasons: invalidChecks, requiredArtifacts });
|
|
28
|
+
const correction = await reviewCorrectionAction({ target, packageRoot, taskId: explicitTaskId, state, context, requiredArtifacts });
|
|
29
|
+
if (correction) return correction;
|
|
30
|
+
return resolveReviewingEvidence(options);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async function resolveReviewingEvidence({ state, context, requiredArtifacts, target, packageRoot, contract, route, preflight, authorityContext, runtimeContext, explicitTaskId, eventsRel, receiptRel, stateRel, policyRecoveryAction }) {
|
|
20
34
|
const evidence = await requirementsAndCoverage({
|
|
21
35
|
target,
|
|
22
36
|
packageRoot,
|
|
@@ -39,11 +53,7 @@ export async function resolveReviewingPhase({ state, context, requiredArtifacts,
|
|
|
39
53
|
if (state.lastCompletionAttempt?.status === "REJECTED") {
|
|
40
54
|
try {
|
|
41
55
|
const ledger = await validateEventLedger(target, packageRoot, { taskId: explicitTaskId, eventsPath: eventsRel });
|
|
42
|
-
|
|
43
|
-
try {
|
|
44
|
-
const receiptArtifact = await readJsonArtifact(target, receiptRel, "execution-receipt", packageRoot);
|
|
45
|
-
currentReceipt = receiptArtifact?.value;
|
|
46
|
-
} catch {}
|
|
56
|
+
const currentReceipt = await readRecoveryReceipt(target, receiptRel, packageRoot);
|
|
47
57
|
const recoveryAuth = validateCompletionRecoveryAuthorization({
|
|
48
58
|
state,
|
|
49
59
|
receipt: currentReceipt,
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
// Bounded parsers for untrusted repository manifest text. They never throw on
|
|
2
|
+
// malformed input: every entry point returns an `invalid` shape instead.
|
|
3
|
+
import { PROJECT_DETECTION_LIMITS } from "./limits.js";
|
|
4
|
+
import { uniqueSorted } from "./shared.js";
|
|
5
|
+
|
|
6
|
+
const MAX_MANIFEST_BYTES = PROJECT_DETECTION_LIMITS.maxManifestBytes;
|
|
7
|
+
const MAX_XML_TEXT_LENGTH = 4096;
|
|
8
|
+
export const DOTNET_SDKS = new Set([
|
|
9
|
+
"Microsoft.NET.Sdk",
|
|
10
|
+
"Microsoft.NET.Sdk.Web",
|
|
11
|
+
"Microsoft.NET.Sdk.Worker",
|
|
12
|
+
"Microsoft.NET.Sdk.Razor",
|
|
13
|
+
"Microsoft.NET.Sdk.BlazorWebAssembly",
|
|
14
|
+
"Aspire.AppHost.Sdk",
|
|
15
|
+
"MSTest.Sdk",
|
|
16
|
+
]);
|
|
17
|
+
const ASPNETCORE_SDKS = new Set([
|
|
18
|
+
"Microsoft.NET.Sdk.Web",
|
|
19
|
+
"Microsoft.NET.Sdk.Razor",
|
|
20
|
+
"Microsoft.NET.Sdk.BlazorWebAssembly",
|
|
21
|
+
]);
|
|
22
|
+
|
|
23
|
+
function invalidDotNetProject() {
|
|
24
|
+
return {
|
|
25
|
+
valid: false,
|
|
26
|
+
sdkStyle: false,
|
|
27
|
+
projectSdks: [],
|
|
28
|
+
targetFrameworks: [],
|
|
29
|
+
frameworkReferences: [],
|
|
30
|
+
packageReferences: [],
|
|
31
|
+
projectReferences: [],
|
|
32
|
+
dotnet: false,
|
|
33
|
+
aspnetcore: false,
|
|
34
|
+
abp: false,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function findXmlTagEnd(text, start) {
|
|
39
|
+
let quote = null;
|
|
40
|
+
for (let index = start; index < text.length; index += 1) {
|
|
41
|
+
const character = text[index];
|
|
42
|
+
if (quote) {
|
|
43
|
+
if (character === quote) quote = null;
|
|
44
|
+
} else if (character === "\"" || character === "'") {
|
|
45
|
+
quote = character;
|
|
46
|
+
} else if (character === ">") {
|
|
47
|
+
return index;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return -1;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function parseXmlAttributes(text) {
|
|
54
|
+
const attributes = {};
|
|
55
|
+
let index = 0;
|
|
56
|
+
while (index < text.length) {
|
|
57
|
+
while (index < text.length && /\s/u.test(text[index])) index += 1;
|
|
58
|
+
if (index >= text.length) break;
|
|
59
|
+
const name = text.slice(index).match(/^[A-Za-z_][A-Za-z0-9_.:-]*/u)?.[0];
|
|
60
|
+
if (!name) return null;
|
|
61
|
+
index += name.length;
|
|
62
|
+
while (index < text.length && /\s/u.test(text[index])) index += 1;
|
|
63
|
+
if (text[index] !== "=") return null;
|
|
64
|
+
index += 1;
|
|
65
|
+
while (index < text.length && /\s/u.test(text[index])) index += 1;
|
|
66
|
+
const quote = text[index];
|
|
67
|
+
if (quote !== "\"" && quote !== "'") return null;
|
|
68
|
+
index += 1;
|
|
69
|
+
const end = text.indexOf(quote, index);
|
|
70
|
+
if (end < 0 || Object.prototype.hasOwnProperty.call(attributes, name)) return null;
|
|
71
|
+
attributes[name] = text.slice(index, end);
|
|
72
|
+
index = end + 1;
|
|
73
|
+
}
|
|
74
|
+
return attributes;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function appendXmlText(stack, value) {
|
|
78
|
+
if (value === "") return true;
|
|
79
|
+
const current = stack[stack.length - 1];
|
|
80
|
+
if (!current) return value.trim() === "";
|
|
81
|
+
current.textParts.push(value);
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function consumeXmlSpecialToken(text, tagStart, stack) {
|
|
86
|
+
if (text.startsWith("<!--", tagStart)) {
|
|
87
|
+
const end = text.indexOf("-->", tagStart + 4);
|
|
88
|
+
return end < 0 ? { valid: false } : { valid: true, nextIndex: end + 3 };
|
|
89
|
+
}
|
|
90
|
+
if (text.startsWith("<![CDATA[", tagStart)) {
|
|
91
|
+
const end = text.indexOf("]]>", tagStart + 9);
|
|
92
|
+
if (end < 0 || stack.length === 0) return { valid: false };
|
|
93
|
+
stack[stack.length - 1].textParts.push(text.slice(tagStart + 9, end));
|
|
94
|
+
return { valid: true, nextIndex: end + 3 };
|
|
95
|
+
}
|
|
96
|
+
if (text.startsWith("<?", tagStart)) {
|
|
97
|
+
const end = text.indexOf("?>", tagStart + 2);
|
|
98
|
+
return end < 0 ? { valid: false } : { valid: true, nextIndex: end + 2 };
|
|
99
|
+
}
|
|
100
|
+
if (text.startsWith("<!", tagStart)) return { valid: false };
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function closeXmlNode(raw, state) {
|
|
105
|
+
const closing = raw.slice(1).trim().match(/^([A-Za-z_][A-Za-z0-9_.:-]*)\s*$/u)?.[1];
|
|
106
|
+
const open = state.stack.pop();
|
|
107
|
+
if (!closing || !open || open.name !== closing) return false;
|
|
108
|
+
open.text = open.textParts.join("");
|
|
109
|
+
if (state.stack.length === 0) {
|
|
110
|
+
if (state.rootClosed || open !== state.root) return false;
|
|
111
|
+
state.rootClosed = true;
|
|
112
|
+
}
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function openXmlNode(raw, state) {
|
|
117
|
+
const selfClosing = /\/\s*$/u.test(raw);
|
|
118
|
+
const body = selfClosing ? raw.replace(/\/\s*$/u, "").trimEnd() : raw;
|
|
119
|
+
const name = body.match(/^([A-Za-z_][A-Za-z0-9_.:-]*)/u)?.[1];
|
|
120
|
+
if (!name) return false;
|
|
121
|
+
if (state.stack.length === 0 && (state.root || state.rootClosed)) return false;
|
|
122
|
+
if (!state.root && state.expectedRoot && name !== state.expectedRoot) return false;
|
|
123
|
+
const attributes = parseXmlAttributes(body.slice(name.length).trim());
|
|
124
|
+
if (!attributes) return false;
|
|
125
|
+
const node = { name, attributes, textParts: [], children: [], text: "" };
|
|
126
|
+
state.nodes.push(node);
|
|
127
|
+
if (state.stack.length > 0) state.stack[state.stack.length - 1].children.push(node);
|
|
128
|
+
if (!state.root) state.root = node;
|
|
129
|
+
if (!selfClosing) state.stack.push(node);
|
|
130
|
+
else if (node === state.root) state.rootClosed = true;
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function consumeXmlTag(text, tagStart, state) {
|
|
135
|
+
const tagEnd = findXmlTagEnd(text, tagStart + 1);
|
|
136
|
+
if (tagEnd < 0) return null;
|
|
137
|
+
const raw = text.slice(tagStart + 1, tagEnd).trim();
|
|
138
|
+
if (raw === "") return null;
|
|
139
|
+
const valid = raw.startsWith("/") ? closeXmlNode(raw, state) : openXmlNode(raw, state);
|
|
140
|
+
return { valid, nextIndex: tagEnd + 1 };
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export function parseXmlStructure(text, expectedRoot = null) {
|
|
144
|
+
if (typeof text !== "string" || text.length > MAX_MANIFEST_BYTES || /\r(?!\n)/u.test(text)) return null;
|
|
145
|
+
const state = { nodes: [], stack: [], root: null, rootClosed: false, expectedRoot };
|
|
146
|
+
let index = 0;
|
|
147
|
+
while (index < text.length) {
|
|
148
|
+
const tagStart = text.indexOf("<", index);
|
|
149
|
+
if (tagStart < 0) break;
|
|
150
|
+
if (!appendXmlText(state.stack, text.slice(index, tagStart))) return null;
|
|
151
|
+
const special = consumeXmlSpecialToken(text, tagStart, state.stack);
|
|
152
|
+
if (special) {
|
|
153
|
+
if (!special.valid) return null;
|
|
154
|
+
index = special.nextIndex;
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
const tag = consumeXmlTag(text, tagStart, state);
|
|
158
|
+
if (!tag?.valid) return null;
|
|
159
|
+
index = tag.nextIndex;
|
|
160
|
+
}
|
|
161
|
+
if (!appendXmlText(state.stack, text.slice(index))) return null;
|
|
162
|
+
if (!state.root || state.stack.length > 0 || !state.rootClosed) return null;
|
|
163
|
+
return { root: state.root, nodes: state.nodes };
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function normalizeSdkName(value) {
|
|
167
|
+
return typeof value === "string" ? value.trim().split("/")[0] : "";
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function xmlValues(nodes, name, attribute = "Include") {
|
|
171
|
+
return uniqueSorted(nodes
|
|
172
|
+
.filter((node) => node.name === name && typeof node.attributes?.[attribute] === "string")
|
|
173
|
+
.map((node) => node.attributes[attribute].trim())
|
|
174
|
+
.filter(Boolean));
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function targetFrameworkValues(nodes) {
|
|
178
|
+
return uniqueSorted(nodes
|
|
179
|
+
.filter((node) => (node.name === "TargetFramework" || node.name === "TargetFrameworks")
|
|
180
|
+
&& node.children.length === 0
|
|
181
|
+
&& node.text.length <= MAX_XML_TEXT_LENGTH)
|
|
182
|
+
.flatMap((node) => node.text.split(";"))
|
|
183
|
+
.map((value) => value.trim())
|
|
184
|
+
.filter(Boolean));
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export function parseDotNetProject(text) {
|
|
188
|
+
const invalid = invalidDotNetProject();
|
|
189
|
+
if (typeof text !== "string" || text.length > MAX_MANIFEST_BYTES) return invalid;
|
|
190
|
+
const document = parseXmlStructure(text, "Project");
|
|
191
|
+
if (!document) return invalid;
|
|
192
|
+
|
|
193
|
+
const sdkValues = [
|
|
194
|
+
document.root.attributes.Sdk ?? "",
|
|
195
|
+
...document.nodes.filter((node) => node.name === "Sdk").map((node) => node.attributes.Name ?? ""),
|
|
196
|
+
];
|
|
197
|
+
const projectSdks = uniqueSorted(sdkValues
|
|
198
|
+
.flatMap((value) => value.split(";"))
|
|
199
|
+
.map(normalizeSdkName)
|
|
200
|
+
.filter(Boolean));
|
|
201
|
+
const recognizedSdks = projectSdks.filter((sdk) => DOTNET_SDKS.has(sdk));
|
|
202
|
+
const frameworkReferences = xmlValues(document.nodes, "FrameworkReference");
|
|
203
|
+
const packageReferences = xmlValues(document.nodes, "PackageReference");
|
|
204
|
+
const projectReferences = xmlValues(document.nodes, "ProjectReference");
|
|
205
|
+
const dotnet = recognizedSdks.length > 0;
|
|
206
|
+
const aspnetcore = dotnet && (recognizedSdks.some((sdk) => ASPNETCORE_SDKS.has(sdk))
|
|
207
|
+
|| frameworkReferences.some((reference) => reference.toLowerCase() === "microsoft.aspnetcore.app"));
|
|
208
|
+
const abp = dotnet && packageReferences.some((reference) => reference.toLowerCase().startsWith("volo.abp."));
|
|
209
|
+
return {
|
|
210
|
+
valid: true,
|
|
211
|
+
sdkStyle: dotnet,
|
|
212
|
+
projectSdks,
|
|
213
|
+
targetFrameworks: targetFrameworkValues(document.nodes),
|
|
214
|
+
frameworkReferences,
|
|
215
|
+
packageReferences,
|
|
216
|
+
projectReferences,
|
|
217
|
+
dotnet,
|
|
218
|
+
aspnetcore,
|
|
219
|
+
abp,
|
|
220
|
+
};
|
|
221
|
+
}
|