Skip to content

Commit 56c9c6b

Browse files
authored
[Types] Upgrade types and include new required model card fields (#2)
* [Types] Upgrade types and include new required model card fields * add codeowners * code review changes
1 parent 2826d68 commit 56c9c6b

File tree

5 files changed

+112
-44
lines changed

5 files changed

+112
-44
lines changed

.github/CODEOWNERS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# CODEOWNERS file for managing repository permissions
2+
# Format: path-pattern @username @org/team-name
3+
4+
# Maintainers: Default owners for all files
5+
* @roostorg/roosters
6+

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Example [COOP](https://github.com/roostorg/coop) integration plugin. Reference r
1010

1111
- **Integration:** `COOP_INTEGRATION_EXAMPLE`
1212
- **Signal 1 – Random Signal Selection** (`RANDOM_SIGNAL_SELECTION`): Returns `true` or `false` at random. The probability (0–100%) comes from the org’s integration config (“True percentage”). Set e.g. `70` in Org settings → Integrations; the signal returns `true` about 70% of the time. Use this to test config saving and boolean conditions.
13-
- **Signal 2 – Random Score** (`RANDOM_SCORE`): Returns a random number between 0 and 1. No integration config needed. In the rule builder you set a **threshold** (e.g. `0.5`) and choose **above** or **below**. Use this to test numeric score conditions (e.g. “score ≥ 0.5” or “score < 0.3”).
13+
- **Signal 2 – Random Score** (`RANDOM_SCORE`): Returns a random number from **0 up to (but not including) 100**—the same 0–100 style as “True percentage,” so thresholds feel consistent. No integration config needed. In the rule builder set a **threshold** (e.g. `50`) and choose **above** or **below**. Use this to test numeric score conditions (e.g. “score ≥ 50” or “score < 30”).
1414

1515
## Install
1616

@@ -61,17 +61,17 @@ Restart the COOP server so it loads the plugin.
6161
1. **Org settings → Integrations** – you should see “COOP Integration Example”. Open it and set **True percentage (0–100)** (e.g. `70`) for Random Signal Selection. Save.
6262
2. **Rules (routing or enforcement)** – when adding a condition:
6363
- **Random Signal Selection**: Pick that signal; the condition uses your configured percentage (true/false).
64-
- **Random Score**: Pick “Random Score”, then set a **threshold** (e.g. `0.5`) and choose **above** or **below**. The rule compares the random score to your threshold.
64+
- **Random Score**: Pick “Random Score”, then set a **threshold** on the 0–100 scale (e.g. `50`) and choose **above** or **below**. The rule compares the random score to your threshold.
6565

6666
## Contract
6767

6868
This package implements the COOP plugin contract from `@roostorg/types`:
6969

7070
- **Default export:** `CoopIntegrationPlugin` with `manifest` and `createSignals(context)`.
71-
- **Manifest:** `id`, `name`, `version`, `requiresConfig`, `configurationFields`, `signalTypeIds`, `modelCard` (with required sections `modelDetails` and `technicalIntegration`).
71+
- **Manifest:** `id`, `name`, `version`, `requiresConfig`, `configurationFields`, `signalTypeIds`, `modelCard` (must include every section id in `REQUIRED_MODEL_CARD_SECTION_IDS` from `@roostorg/types`; call `assertModelCardHasRequiredSections(modelCard)` when registering).
7272
- **createSignals:** Returns two descriptors:
7373
- `RANDOM_SIGNAL_SELECTION`: `run(input)` uses `context.getCredential(orgId)` for true percentage; returns `{ outputType: { scalarType: 'BOOLEAN' }, score: boolean }`.
74-
- `RANDOM_SCORE`: `run()` returns `{ outputType: { scalarType: 'NUMBER' }, score: number }` in [0, 1]; no config. Threshold is set in the rule (above/below).
74+
- `RANDOM_SCORE`: `run()` returns `{ outputType: { scalarType: 'NUMBER' }, score: number }` in **[0, 100)** (`Math.random() * 100`); no config. Threshold is set in the rule on the same scale (above/below).
7575

7676
## Publishing
7777

package-lock.json

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@roostorg/coop-integration-example",
3-
"version": "1.0.0",
3+
"version": "2.0.0",
44
"description": "Example package to show how a custom integration and signal can be used in COOP this is meant to be a reference repository and provide basic determination",
55
"type": "module",
66
"main": "dist/index.js",
@@ -23,7 +23,7 @@
2323
"example"
2424
],
2525
"author": "Roostorg",
26-
"license": "apache-2.0",
26+
"license": "Apache-2.0",
2727
"repository": {
2828
"type": "git",
2929
"url": "https://github.com/roostorg/coop-integration-example.git"
@@ -33,10 +33,10 @@
3333
},
3434
"homepage": "https://github.com/roostorg/coop-integration-example#readme",
3535
"peerDependencies": {
36-
"@roostorg/types": ">=1.0.0"
36+
"@roostorg/types": ">=2.0.0"
3737
},
3838
"devDependencies": {
39-
"@roostorg/types": "^1.1.1",
39+
"@roostorg/types": "^2.0.0",
4040
"typescript": "^5.0.0"
4141
},
4242
"engines": {

src/index.ts

Lines changed: 90 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
/**
22
* Example COOP integration plugin with two signal types:
33
* 1. Random Signal Selection – boolean, probability from org config (tests config saving).
4-
* 2. Random Score – numeric [0, 1], threshold set in the rule (tests score vs threshold).
4+
* 2. Random Score – numeric 0–100, threshold set in the rule (tests score vs threshold).
55
*/
66

7-
import type {
8-
CoopIntegrationPlugin,
9-
IntegrationManifest,
10-
ModelCard,
11-
PluginSignalContext,
12-
PluginSignalDescriptor,
7+
import {
8+
assertModelCardHasRequiredSections,
9+
type CoopIntegrationPlugin,
10+
type IntegrationManifest,
11+
type ModelCard,
12+
type PluginSignalContext,
13+
type PluginSignalDescriptor,
1314
} from '@roostorg/types';
1415

1516
const SIGNAL_TYPE_RANDOM_SELECTION = 'RANDOM_SIGNAL_SELECTION';
@@ -19,49 +20,111 @@ const DEFAULT_TRUE_PERCENTAGE = 50;
1920

2021
const modelCard: ModelCard = {
2122
modelName: 'COOP Integration Example',
22-
version: '1.0.0',
23-
releaseDate: '2026',
23+
version: '2.0.0',
24+
releaseDate: 'March 2026',
2425
sections: [
2526
{
26-
id: 'modelDetails',
27-
title: 'Model Details',
27+
id: 'trainingData',
28+
title: 'Training Data',
2829
fields: [
29-
{ label: 'Model Name', value: 'COOP Integration Example' },
3030
{
31-
label: 'Purpose',
31+
label: 'Overview',
3232
value:
33-
'Example plugin with two signals: one uses org config (boolean), one returns a numeric score so you can set a threshold in the rule (over/under).',
33+
'This reference integration does not use a trained model. Outputs are randomly generated for demonstration and testing of COOP rules, configuration, and UI only.',
3434
},
35+
],
36+
},
37+
{
38+
id: 'policyAndTaxonomy',
39+
title: 'Policy and Taxonomy',
40+
fields: [
41+
{
42+
label: 'Scope',
43+
value:
44+
'Not a content policy engine. Signals are placeholders: boolean “coin flip” with configurable probability and a numeric random score for threshold exercises in rules.',
45+
},
46+
],
47+
},
48+
{
49+
id: 'annotationMethodology',
50+
title: 'Annotation Methodology',
51+
fields: [
52+
{
53+
label: 'Method',
54+
value:
55+
'No human or automated labeling pipeline. Values are produced with Math.random() (or equivalent logic) at evaluation time.',
56+
},
57+
],
58+
},
59+
{
60+
id: 'performanceBenchmarks',
61+
title: 'Performance and Benchmarks',
62+
fields: [
63+
{
64+
label: 'Benchmarks',
65+
value:
66+
'No precision, recall, or latency benchmarks apply. Do not use performance claims from this package in production decisions.',
67+
},
68+
],
69+
},
70+
{
71+
id: 'biasAndLimitations',
72+
title: 'Bias and Limitations',
73+
fields: [
74+
{
75+
label: 'Limitations',
76+
value:
77+
'Outputs are uncorrelated with input content. Unsuitable for safety, compliance, or moderation decisions. For integration testing and developer learning only.',
78+
},
79+
],
80+
},
81+
{
82+
id: 'implementationGuidance',
83+
title: 'Implementation Guidance',
84+
fields: [
3585
{
3686
label: 'Signals',
37-
value: `${SIGNAL_TYPE_RANDOM_SELECTION} (boolean, config-driven) and ${SIGNAL_TYPE_RANDOM_SCORE} (number 0–1, threshold in rule).`,
87+
value: `${SIGNAL_TYPE_RANDOM_SELECTION} (boolean; org config truePercentage 0–100). ${SIGNAL_TYPE_RANDOM_SCORE} (number 0–100; set threshold and above/below in the rule).`,
88+
},
89+
{
90+
label: 'Configuration',
91+
value:
92+
'Random Signal Selection requires org integration config (true percentage). Random Score requires no integration config.',
93+
},
94+
{
95+
label: 'Versioning',
96+
value:
97+
'modelCard.version and manifest.version identify this integration plugin release. They are independent of the @roostorg/types dependency major version (e.g. 2.x).',
3898
},
3999
],
40100
},
41101
{
42-
id: 'technicalIntegration',
43-
title: 'Technical Integration',
102+
id: 'relevantLinks',
103+
title: 'Relevant Links',
44104
fields: [
45105
{
46-
label: 'Signal types',
47-
value: `${SIGNAL_TYPE_RANDOM_SELECTION}, ${SIGNAL_TYPE_RANDOM_SCORE}`,
106+
label: 'Repository',
107+
value: 'https://github.com/roostorg/coop-integration-example',
48108
},
49109
{
50-
label: 'Config',
51-
value: 'truePercentage (0–100) for Random Signal Selection only; Random Score needs no config.',
110+
label: 'Documentation',
111+
value: 'https://roostorg.github.io/coop/INTEGRATIONS_PLUGIN.html',
52112
},
53113
],
54114
},
55115
],
56116
};
57117

118+
assertModelCardHasRequiredSections(modelCard);
119+
58120
const manifest: IntegrationManifest = {
59121
id: INTEGRATION_ID,
60122
name: 'COOP Integration Example',
61-
version: '1.0.0',
123+
/** Same semver as modelCard.version: this plugin’s release, not @roostorg/types. */
124+
version: '2.0.0',
62125
description:
63126
'Example plugin with two signals: config-driven boolean and a numeric score you compare with a threshold in the rule.',
64-
docsUrl: 'https://github.com/roostorg/coop/tree/main/coop-integration-example',
127+
docsUrl: 'https://roostorg.github.io/coop/INTEGRATIONS_PLUGIN.html',
65128
requiresConfig: true,
66129
configurationFields: [
67130
{
@@ -158,11 +221,11 @@ function createRandomScoreDescriptor(
158221
id: { type: SIGNAL_TYPE_RANDOM_SCORE },
159222
displayName: 'Random Score',
160223
description:
161-
'Returns a random number between 0 and 1. Set a threshold in the rule (e.g. 0.5) and choose "above" or "below" to test numeric conditions.',
224+
'Returns a random number from 0 up to (but not including) 100. Set a threshold in the rule (e.g. 50) and choose "above" or "below" to test numeric conditions.',
162225
docsUrl: null,
163226
recommendedThresholds: {
164-
highPrecisionThreshold: 0.5,
165-
highRecallThreshold: 0.5,
227+
highPrecisionThreshold: 50,
228+
highRecallThreshold: 50,
166229
},
167230
supportedLanguages: 'ALL',
168231
pricingStructure: { type: 'FREE' },
@@ -178,8 +241,7 @@ function createRandomScoreDescriptor(
178241
async run(
179242
_input: unknown,
180243
): Promise<{ outputType: typeof outputType; score: number }> {
181-
// Returns a random number between 0 and 100.
182-
// Because outputType is { scalarType: 'NUMBER' }, Coop can take the score and compare it to a threshold in the rule.
244+
// [0, 100) — same scale as percentages elsewhere in this plugin (e.g. truePercentage).
183245
const score = Math.random() * 100;
184246
return { outputType, score };
185247
},

0 commit comments

Comments
 (0)