@company-semantics/contracts 0.47.2 → 0.49.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 +4 -1
- package/src/index.ts +5 -10
- package/src/ralph/index.ts +1 -13
- package/src/ralph/progress.ts +2 -4
- package/src/rate-limit/README.md +51 -0
- package/src/rate-limit/index.ts +23 -0
- package/src/ralph/trust.ts +0 -125
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@company-semantics/contracts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.49.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -51,6 +51,7 @@
|
|
|
51
51
|
"access": "public"
|
|
52
52
|
},
|
|
53
53
|
"scripts": {
|
|
54
|
+
"build": "tsc -b --noEmit",
|
|
54
55
|
"typecheck": "tsc -b --noEmit",
|
|
55
56
|
"typecheck:ci": "tsc -p scripts/ci/tsconfig.json",
|
|
56
57
|
"lint:md": "markdownlint-cli2 '**/*.md' '#node_modules'",
|
|
@@ -67,6 +68,8 @@
|
|
|
67
68
|
"guard:version-tag:json": "npx tsx scripts/ci/version-tag-guard.ts --json",
|
|
68
69
|
"guard:decisions-deprecation": "npx tsx scripts/ci/decisions-deprecation-guard.ts",
|
|
69
70
|
"guard:decisions-deprecation:json": "npx tsx scripts/ci/decisions-deprecation-guard.ts --json",
|
|
71
|
+
"guard:quick": "pnpm guard:export && pnpm guard:vocabulary && pnpm guard:scripts-deps",
|
|
72
|
+
"guard": "pnpm guard:export && pnpm guard:vocabulary && pnpm guard:scripts-deps && pnpm guard:decision && pnpm guard:decisions-deprecation",
|
|
70
73
|
"guard:test": "vitest run scripts/ci/__tests__",
|
|
71
74
|
"release": "npx tsx scripts/release.ts",
|
|
72
75
|
"prepublishOnly": "echo 'ERROR: Publishing is CI-only via tag push. Use pnpm release instead.' && exit 1",
|
package/src/index.ts
CHANGED
|
@@ -332,17 +332,12 @@ export type {
|
|
|
332
332
|
RalphIteration,
|
|
333
333
|
RalphMode,
|
|
334
334
|
RalphProgress,
|
|
335
|
-
// Trust types
|
|
336
|
-
RalphTrustLevel,
|
|
337
|
-
RalphRunResult,
|
|
338
|
-
RalphCIStatus,
|
|
339
|
-
RalphTrustLog,
|
|
340
|
-
RalphTL1Policy,
|
|
341
|
-
RalphTL2Policy,
|
|
342
|
-
RalphTL3Policy,
|
|
343
|
-
RalphTrustPolicy,
|
|
344
|
-
RalphDemotionReason,
|
|
345
335
|
} from './ralph/index';
|
|
346
336
|
|
|
347
337
|
// Ralph constants (cross-repo support)
|
|
348
338
|
export { REPO_PRECEDENCE } from './ralph/index'
|
|
339
|
+
|
|
340
|
+
// Rate limit domain types
|
|
341
|
+
// @see PRD-00013 for contracts integration
|
|
342
|
+
export type { RateLimitConfig, RateLimitResult } from './rate-limit/index'
|
|
343
|
+
export { RateLimitTier } from './rate-limit/index'
|
package/src/ralph/index.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Import from '@company-semantics/contracts/ralph' or '@company-semantics/contracts'.
|
|
6
6
|
*
|
|
7
7
|
* Note: This module exports types only (no runtime code per contracts policy).
|
|
8
|
-
* Orchestration
|
|
8
|
+
* Orchestration and prompts live in company-semantics-control.
|
|
9
9
|
*
|
|
10
10
|
* @see company-semantics-control/docs/ralph.md for usage
|
|
11
11
|
*/
|
|
@@ -40,15 +40,3 @@ export type {
|
|
|
40
40
|
RalphProgress,
|
|
41
41
|
} from './progress';
|
|
42
42
|
|
|
43
|
-
// Trust types
|
|
44
|
-
export type {
|
|
45
|
-
RalphTrustLevel,
|
|
46
|
-
RalphRunResult,
|
|
47
|
-
RalphCIStatus,
|
|
48
|
-
RalphTrustLog,
|
|
49
|
-
RalphTL1Policy,
|
|
50
|
-
RalphTL2Policy,
|
|
51
|
-
RalphTL3Policy,
|
|
52
|
-
RalphTrustPolicy,
|
|
53
|
-
RalphDemotionReason,
|
|
54
|
-
} from './trust';
|
package/src/ralph/progress.ts
CHANGED
|
@@ -11,8 +11,6 @@
|
|
|
11
11
|
* @see company-semantics-control/docs/ralph.md for usage
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
import type { RalphTrustLevel } from './trust';
|
|
15
|
-
|
|
16
14
|
// =============================================================================
|
|
17
15
|
// Iteration Types
|
|
18
16
|
// =============================================================================
|
|
@@ -60,8 +58,8 @@ export type RalphProgress = {
|
|
|
60
58
|
sessionId: string;
|
|
61
59
|
/** Target repository name */
|
|
62
60
|
repo: string;
|
|
63
|
-
/**
|
|
64
|
-
trustLevel
|
|
61
|
+
/** @deprecated Trust level removed — field retained for serialization compat */
|
|
62
|
+
trustLevel?: number;
|
|
65
63
|
/** Operation mode (HITL or AFK) */
|
|
66
64
|
mode: RalphMode;
|
|
67
65
|
/** Completed iterations */
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Rate Limit Domain
|
|
2
|
+
|
|
3
|
+
Shared vocabulary types for rate limiting across Company Semantics codebases.
|
|
4
|
+
|
|
5
|
+
## Types
|
|
6
|
+
|
|
7
|
+
### RateLimitTier
|
|
8
|
+
|
|
9
|
+
Enum defining the rate limit tiers available to users:
|
|
10
|
+
|
|
11
|
+
- `FREE` - Default tier for free users
|
|
12
|
+
- `PRO` - Elevated limits for pro subscribers
|
|
13
|
+
- `ENTERPRISE` - Custom limits for enterprise customers
|
|
14
|
+
|
|
15
|
+
### RateLimitConfig
|
|
16
|
+
|
|
17
|
+
Configuration for rate limit windows:
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
interface RateLimitConfig {
|
|
21
|
+
maxRequests: number; // Maximum requests allowed in window
|
|
22
|
+
windowMs: number; // Window duration in milliseconds
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### RateLimitResult
|
|
27
|
+
|
|
28
|
+
Result of a rate limit check:
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
interface RateLimitResult {
|
|
32
|
+
allowed: boolean; // true = permitted, false = rate limited
|
|
33
|
+
remaining: number; // Requests remaining in current window
|
|
34
|
+
resetAt: number; // Unix timestamp when window resets
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Semantic Convention
|
|
39
|
+
|
|
40
|
+
This domain uses `allowed: boolean` where `true` means the request is permitted.
|
|
41
|
+
This is the canonical semantic across all Company Semantics repos.
|
|
42
|
+
|
|
43
|
+
## Consumers
|
|
44
|
+
|
|
45
|
+
- `company-semantics-edge` - Rate limiter implementation
|
|
46
|
+
- `company-semantics-backend` - Rate limit service
|
|
47
|
+
|
|
48
|
+
## See Also
|
|
49
|
+
|
|
50
|
+
- PRD-00012: Foundational rate limiting implementation
|
|
51
|
+
- PRD-00013: Contracts integration (this promotion)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rate limiting vocabulary types.
|
|
3
|
+
* @see PRD-00012 for foundational implementation
|
|
4
|
+
* @see PRD-00013 for contracts integration
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export enum RateLimitTier {
|
|
8
|
+
FREE = 'free',
|
|
9
|
+
PRO = 'pro',
|
|
10
|
+
ENTERPRISE = 'enterprise',
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface RateLimitConfig {
|
|
14
|
+
maxRequests: number;
|
|
15
|
+
windowMs: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface RateLimitResult {
|
|
19
|
+
/** Whether the request is allowed (true = permitted, false = rate limited) */
|
|
20
|
+
allowed: boolean;
|
|
21
|
+
remaining: number;
|
|
22
|
+
resetAt: number;
|
|
23
|
+
}
|
package/src/ralph/trust.ts
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Ralph Trust Level Types
|
|
3
|
-
*
|
|
4
|
-
* Defines the Trust Promotion framework for graduated AI autonomy.
|
|
5
|
-
* Ralph earns trust through repeated, measurable compliance — not intent.
|
|
6
|
-
*
|
|
7
|
-
* Trust Level Summary:
|
|
8
|
-
* - TL0 (Sandbox): Default, no network, single repo
|
|
9
|
-
* - TL1 (Verified): Earned after 8+ consecutive clean runs
|
|
10
|
-
* - TL2 (Limited Network): Requires human approval, npm/GitHub access
|
|
11
|
-
* - TL3 (Full AFK): Rare, mechanical tasks only, full network
|
|
12
|
-
*
|
|
13
|
-
* @see company-semantics-control/docs/ralph.md for usage
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
// =============================================================================
|
|
17
|
-
// Trust Level Types
|
|
18
|
-
// =============================================================================
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Trust level numeric value.
|
|
22
|
-
*
|
|
23
|
-
* - 0: Sandbox (default)
|
|
24
|
-
* - 1: Verified AFK
|
|
25
|
-
* - 2: Limited Network
|
|
26
|
-
* - 3: Full AFK
|
|
27
|
-
*/
|
|
28
|
-
export type RalphTrustLevel = 0 | 1 | 2 | 3;
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Result of a Ralph run.
|
|
32
|
-
*/
|
|
33
|
-
export type RalphRunResult = 'success' | 'failure';
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* CI status after a Ralph run.
|
|
37
|
-
*/
|
|
38
|
-
export type RalphCIStatus = 'green' | 'red' | 'skipped';
|
|
39
|
-
|
|
40
|
-
// =============================================================================
|
|
41
|
-
// Trust Log Types
|
|
42
|
-
// =============================================================================
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Record of a single Ralph run outcome.
|
|
46
|
-
*
|
|
47
|
-
* Stored in `.ralph/trust-log.json` for audit and promotion decisions.
|
|
48
|
-
*/
|
|
49
|
-
export type RalphTrustLog = {
|
|
50
|
-
/** Run identifier (ISO timestamp) */
|
|
51
|
-
runId: string;
|
|
52
|
-
/** Repository where run occurred */
|
|
53
|
-
repo: string;
|
|
54
|
-
/** Trust level at time of run */
|
|
55
|
-
trustLevel: RalphTrustLevel;
|
|
56
|
-
/** Overall run result */
|
|
57
|
-
result: RalphRunResult;
|
|
58
|
-
/** CI status after run */
|
|
59
|
-
ciStatus: RalphCIStatus;
|
|
60
|
-
/** Whether human fixes were required post-run */
|
|
61
|
-
humanFixesRequired: boolean;
|
|
62
|
-
/** Reason for demotion if applicable */
|
|
63
|
-
demotionReason?: string;
|
|
64
|
-
/** Number of iterations completed */
|
|
65
|
-
iterationsCompleted?: number;
|
|
66
|
-
/** Number of features completed */
|
|
67
|
-
featuresCompleted?: number;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
// =============================================================================
|
|
71
|
-
// Trust Policy Types
|
|
72
|
-
// =============================================================================
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Promotion criteria for TL1 (Verified AFK).
|
|
76
|
-
*/
|
|
77
|
-
export type RalphTL1Policy = {
|
|
78
|
-
requiredConsecutiveRuns: number;
|
|
79
|
-
allowNetwork: false;
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Promotion criteria for TL2 (Limited Network).
|
|
84
|
-
*/
|
|
85
|
-
export type RalphTL2Policy = {
|
|
86
|
-
requiresHumanApproval: true;
|
|
87
|
-
/** Domains allowed for network access */
|
|
88
|
-
networkAllowlist: string[];
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Promotion criteria for TL3 (Full AFK).
|
|
93
|
-
*/
|
|
94
|
-
export type RalphTL3Policy = {
|
|
95
|
-
requiresExplicitPromotion: true;
|
|
96
|
-
/** Glob patterns for allowed repos */
|
|
97
|
-
allowedRepoPatterns: string[];
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Complete trust policy configuration.
|
|
102
|
-
*
|
|
103
|
-
* Note: Policy logic lives in control repo, not here.
|
|
104
|
-
* This type defines vocabulary only.
|
|
105
|
-
*/
|
|
106
|
-
export type RalphTrustPolicy = {
|
|
107
|
-
trustLevel1: RalphTL1Policy;
|
|
108
|
-
trustLevel2: RalphTL2Policy;
|
|
109
|
-
trustLevel3: RalphTL3Policy;
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
// =============================================================================
|
|
113
|
-
// Demotion Types
|
|
114
|
-
// =============================================================================
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Reasons for automatic demotion to TL0.
|
|
118
|
-
*/
|
|
119
|
-
export type RalphDemotionReason =
|
|
120
|
-
| 'ci_failed'
|
|
121
|
-
| 'guard_violation'
|
|
122
|
-
| 'manual_patch_required'
|
|
123
|
-
| 'scope_violation'
|
|
124
|
-
| 'network_abuse'
|
|
125
|
-
| 'prd_marked_complete_incorrectly';
|