Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions apps/gittensory-ui/public/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -4296,16 +4296,20 @@
},
"credibilityFloor": {
"type": "number"
},

Check notice on line 4299 in apps/gittensory-ui/public/openapi.json

View check run for this annotation

Deleted GitHub App / Gittensory Context

Issue discovery is disabled for this repo

This repo is configured for direct contribution review rather than issue-discovery flow.
"credibilityObserved": {
"type": "number"
},
"reviewCollateralMultiplier": {
"type": "number"
}
},
"required": [
"baseTokenGatePassed",
"openPrThreshold",
"openPrCount",
"collateralFraction",
"reviewCollateralMultiplier",
"credibilityFloor",
"credibilityObserved"
]
Expand Down Expand Up @@ -4551,13 +4555,17 @@
},
"credibilityObserved": {
"type": "number"
},
"reviewCollateralMultiplier": {
"type": "number"
}
},
"required": [
"baseTokenGatePassed",
"openPrThreshold",
"openPrCount",
"collateralFraction",
"reviewCollateralMultiplier",
"credibilityFloor",
"credibilityObserved"
]
Expand Down Expand Up @@ -4803,13 +4811,17 @@
},
"credibilityObserved": {
"type": "number"
},
"reviewCollateralMultiplier": {
"type": "number"
}
},
"required": [
"baseTokenGatePassed",
"openPrThreshold",
"openPrCount",
"collateralFraction",
"reviewCollateralMultiplier",
"credibilityFloor",
"credibilityObserved"
]
Expand Down Expand Up @@ -5055,13 +5067,17 @@
},
"credibilityObserved": {
"type": "number"
},
"reviewCollateralMultiplier": {
"type": "number"
}
},
"required": [
"baseTokenGatePassed",
"openPrThreshold",
"openPrCount",
"collateralFraction",
"reviewCollateralMultiplier",
"credibilityFloor",
"credibilityObserved"
]
Expand Down Expand Up @@ -5307,13 +5323,17 @@
},
"credibilityObserved": {
"type": "number"
},
"reviewCollateralMultiplier": {
"type": "number"
}
},
"required": [
"baseTokenGatePassed",
"openPrThreshold",
"openPrCount",
"collateralFraction",
"reviewCollateralMultiplier",
"credibilityFloor",
"credibilityObserved"
]
Expand Down Expand Up @@ -6207,13 +6227,17 @@
},
"credibilityObserved": {
"type": "number"
},
"reviewCollateralMultiplier": {
"type": "number"
}
},
"required": [
"baseTokenGatePassed",
"openPrThreshold",
"openPrCount",
"collateralFraction",
"reviewCollateralMultiplier",
"credibilityFloor",
"credibilityObserved"
]
Expand Down Expand Up @@ -6455,13 +6479,17 @@
},
"credibilityObserved": {
"type": "number"
},
"reviewCollateralMultiplier": {
"type": "number"
}
},
"required": [
"baseTokenGatePassed",
"openPrThreshold",
"openPrCount",
"collateralFraction",
"reviewCollateralMultiplier",
"credibilityFloor",
"credibilityObserved"
]
Expand Down
2 changes: 2 additions & 0 deletions src/api/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@
status: z.enum(["passed", "failed", "not_run", "skipped", "focused", "unknown"]),
summary: z.string().max(MAX_LOCAL_BRANCH_TEXT_CHARS).optional(),
durationMs: z.number().int().min(0).optional(),
exitCode: z.number().int().min(0).optional(),

Check notice on line 446 in src/api/routes.ts

View check run for this annotation

Deleted GitHub App / Gittensory Context

Issue discovery is disabled for this repo

This repo is configured for direct contribution review rather than issue-discovery flow.
})
.strict();

Expand All @@ -456,6 +456,7 @@
sourceLines: z.number().min(0).optional(),
testTokenScore: z.number().min(0).optional(),
nonCodeTokenScore: z.number().min(0).optional(),
nonCodeLines: z.number().min(0).optional(),
warnings: z.array(z.string().max(MAX_LOCAL_SCORER_WARNING_CHARS)).max(MAX_LOCAL_SCORER_WARNING_COUNT).optional(),
})
.strict();
Expand Down Expand Up @@ -533,6 +534,7 @@
sourceLines: z.number().min(0).optional(),
testTokenScore: z.number().min(0).optional(),
nonCodeTokenScore: z.number().min(0).optional(),
nonCodeLines: z.number().min(0).optional(),
existingContributorTokenScore: z.number().min(0).optional(),
prAgeHours: z.number().min(0).optional(),
openPrCount: z.number().int().min(0).optional(),
Expand Down
1 change: 1 addition & 0 deletions src/openapi/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1228,9 +1228,10 @@

const ScoreGatesSchema = z.object({
baseTokenGatePassed: z.boolean(),
openPrThreshold: z.number(),

Check notice on line 1231 in src/openapi/schemas.ts

View check run for this annotation

Deleted GitHub App / Gittensory Context

Issue discovery is disabled for this repo

This repo is configured for direct contribution review rather than issue-discovery flow.
openPrCount: z.number(),
collateralFraction: z.number(),
reviewCollateralMultiplier: z.number(),
credibilityFloor: z.number(),
credibilityObserved: z.number(),
});
Expand Down
3 changes: 1 addition & 2 deletions src/registry/normalize.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { DEFAULT_ISSUE_DISCOVERY_SHARE } from "../scoring/model";

Check notice on line 1 in src/registry/normalize.ts

View check run for this annotation

Deleted GitHub App / Gittensory Context

Issue discovery is disabled for this repo

This repo is configured for direct contribution review rather than issue-discovery flow.
import type { JsonValue, RegistryRepoConfig, RegistrySnapshot, RepoTimeDecayOverrides } from "../types";

type RawRepoConfig = Record<string, JsonValue>;

const DEFAULT_ISSUE_DISCOVERY_SHARE = 0.5;

export function normalizeRegistryPayload(payload: unknown, source: RegistrySnapshot["source"], fetchedAt: string): RegistrySnapshot {
const repos = extractRepoEntries(payload).map(([repo, config]) => normalizeRepo(repo, config));
const totalEmissionShare = repos.reduce((sum, repo) => sum + repo.emissionShare, 0);
Expand Down
5 changes: 5 additions & 0 deletions src/scoring/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
} from "../db/repositories";
import { getLatestRegistrySnapshot } from "../registry/sync";
import { syncUnmodeledScoringConstantDrift } from "../upstream/unmodeled-scoring-drift";
import type { JsonValue, ScoringModelSnapshotRecord } from "../types";

Check notice on line 7 in src/scoring/model.ts

View check run for this annotation

Deleted GitHub App / Gittensory Context

Issue discovery is disabled for this repo

This repo is configured for direct contribution review rather than issue-discovery flow.
import { errorMessage, nowIso } from "../utils/json";

export const DEFAULT_ISSUE_DISCOVERY_SHARE = 0.5;

export const DEFAULT_SCORING_CONSTANTS: Record<string, number> = {
OSS_EMISSION_SHARE: 0.9,
// Upstream name is ISSUES_TREASURY_EMISSION_SHARE (plural). The prior singular spelling never matched
Expand All @@ -28,6 +30,9 @@
OPEN_ISSUE_SPAM_TOKEN_SCORE_PER_SLOT: 300,
MAX_OPEN_ISSUE_THRESHOLD: 30,
OPEN_PR_COLLATERAL_PERCENT: 0.2,
MAX_OPEN_PR_REVIEW_COLLATERAL_MULTIPLIER: 2.0,
MAX_LINES_SCORED_FOR_NON_CODE_EXT: 300,
DEFAULT_ISSUE_DISCOVERY_SHARE,
REVIEW_PENALTY_RATE: 0.15,
STANDARD_ISSUE_MULTIPLIER: 1.33,
MAINTAINER_ISSUE_MULTIPLIER: 1.66,
Expand Down
29 changes: 26 additions & 3 deletions src/scoring/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
linkedIssueContext?: LinkedIssueMultiplierContext | undefined;
sourceTokenScore?: number | undefined;
totalTokenScore?: number | undefined;
sourceLines?: number | undefined;

Check notice on line 14 in src/scoring/preview.ts

View check run for this annotation

Deleted GitHub App / Gittensory Context

Issue discovery is disabled for this repo

This repo is configured for direct contribution review rather than issue-discovery flow.
testTokenScore?: number | undefined;
nonCodeTokenScore?: number | undefined;
/** Raw non-code line count before upstream's MAX_LINES_SCORED_FOR_NON_CODE_EXT cap. */
nonCodeLines?: number | undefined;
existingContributorTokenScore?: number | undefined;
openPrCount?: number | undefined;
credibility?: number | undefined;
Expand Down Expand Up @@ -167,7 +169,10 @@
baseTokenGatePassed: boolean;
openPrThreshold: number;
openPrCount: number;
/** Effective open-PR collateral fraction (OPEN_PR_COLLATERAL_PERCENT × reviewCollateralMultiplier). */
collateralFraction: number;
/** Upstream open-PR review-collateral multiplier from CHANGES_REQUESTED reviews (≥ 1, capped). */
reviewCollateralMultiplier: number;
credibilityFloor: number;
credibilityObserved: number;
};
Expand Down Expand Up @@ -288,7 +293,10 @@
const directPrSlice = repoSlice * (1 - issueDiscoveryShare);
const issueDiscoverySlice = repoSlice * issueDiscoveryShare;
const sourceTokenScore = nonNegative(input.sourceTokenScore);
const totalTokenScore = nonNegative(input.totalTokenScore ?? sourceTokenScore + nonNegative(input.testTokenScore) + nonNegative(input.nonCodeTokenScore));
const cappedNonCodeTokenScore = applyNonCodeLineCap(input, constants);
const totalTokenScore = nonNegative(
input.totalTokenScore ?? sourceTokenScore + nonNegative(input.testTokenScore) + cappedNonCodeTokenScore,
);
const sourceLines = Math.max(1, nonNegative(input.sourceLines ?? sourceTokenScore));
const fixedBaseScore = input.fixedBaseScore ?? config?.fixedBaseScore ?? undefined;
const rawDensity = sourceTokenScore / sourceLines;
Expand All @@ -315,7 +323,13 @@
const credibilityFloor = constant(constants, "MIN_CREDIBILITY", 0.8);
const credibilityMultiplier = credibilityObserved >= credibilityFloor ? 1 : credibilityObserved / credibilityFloor;
const changesRequestedCount = nonNegative(input.changesRequestedCount);
const reviewPenaltyMultiplier = clamp(1 - changesRequestedCount * constant(constants, "REVIEW_PENALTY_RATE", 0.15), 0, 1);
const reviewPenaltyRate = constant(constants, "REVIEW_PENALTY_RATE", 0.15);
const reviewPenaltyMultiplier = clamp(1 - changesRequestedCount * reviewPenaltyRate, 0, 1);
const reviewCollateralMultiplier = Math.min(
constant(constants, "MAX_OPEN_PR_REVIEW_COLLATERAL_MULTIPLIER", 2.0),
1 + changesRequestedCount * reviewPenaltyRate,
);
const openPrCollateralPercent = constant(constants, "OPEN_PR_COLLATERAL_PERCENT", 0.2);
const openPrCount = nonNegative(input.openPrCount);
// The concurrency allowance is earned from the contributor's established merged-history token
// score; the planned PR's own tokens (totalTokenScore) must not inflate its own open-PR threshold.
Expand Down Expand Up @@ -361,7 +375,8 @@
baseTokenGatePassed,
openPrThreshold,
openPrCount,
collateralFraction: constant(constants, "OPEN_PR_COLLATERAL_PERCENT", 0.2),
reviewCollateralMultiplier: roundScore(reviewCollateralMultiplier),
collateralFraction: roundScore(openPrCollateralPercent * reviewCollateralMultiplier),
credibilityFloor,
credibilityObserved,
},
Expand Down Expand Up @@ -911,6 +926,14 @@
return clamp(0.75 + merged * 0.04 - stale * 0.03 - unlinked * 0.02, 0.25, 1);
}

function applyNonCodeLineCap(input: Pick<ScorePreviewInput, "nonCodeTokenScore" | "nonCodeLines">, constants: Record<string, number>): number {
const score = nonNegative(input.nonCodeTokenScore);
const lines = nonNegative(input.nonCodeLines);
if (score <= 0 || lines <= 0) return score;
const maxLines = constant(constants, "MAX_LINES_SCORED_FOR_NON_CODE_EXT", 300);
return lines <= maxLines ? score : score * (maxLines / lines);
}

function constant(constants: Record<string, number>, key: string, fallback: number): number {
const value = constants[key];
return typeof value === "number" && Number.isFinite(value) ? value : fallback;
Expand Down
1 change: 1 addition & 0 deletions src/signals/local-branch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@
observedPullRequestScenarios: ObservedPullRequestScenarios;
duplicateRiskCount: number;
}): ScorePreviewInput {
const scorer = args.input.localScorer;

Check notice on line 455 in src/signals/local-branch.ts

View check run for this annotation

Deleted GitHub App / Gittensory Context

Issue discovery is disabled for this repo

This repo is configured for direct contribution review rather than issue-discovery flow.
const testLineCount = args.changedFiles.filter((file) => isTestFile(file.path)).reduce((sum, file) => sum + nonNegative(file.additions) + nonNegative(file.deletions), 0);
const sourceLineCount = args.changedFiles
.filter((file) => isCodeFile(file.path))
Expand All @@ -471,6 +471,7 @@
sourceLines: scorer?.sourceLines ?? Math.max(1, sourceLineCount || args.changedLineCount || 1),
testTokenScore: scorer?.testTokenScore ?? testLineCount,
nonCodeTokenScore: scorer?.nonCodeTokenScore ?? nonCodeLineCount,
nonCodeLines: nonCodeLineCount,
openPrCount: args.outcomeHistory.totals.openPullRequests,
credibility: args.repoOutcome?.credibility ?? args.outcomeHistory.totals.credibility,
metadataOnly: scorer?.mode !== "gittensor_root" && scorer?.mode !== "external_command",
Expand Down
10 changes: 9 additions & 1 deletion test/unit/registry.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { afterEach, describe, expect, it, vi } from "vitest";

Check notice on line 1 in test/unit/registry.test.ts

View check run for this annotation

Deleted GitHub App / Gittensory Context

Issue discovery is disabled for this repo

This repo is configured for direct contribution review rather than issue-discovery flow.
import { getRepository, upsertRepositoryFromGitHub } from "../../src/db/repositories";
import { normalizeRegistryPayload } from "../../src/registry/normalize";
import { DEFAULT_ISSUE_DISCOVERY_SHARE } from "../../src/scoring/model";
import { getLatestRegistrySnapshot, persistRegistrySnapshot, refreshRegistry } from "../../src/registry/sync";
import { createTestEnv } from "../helpers/d1";

Expand Down Expand Up @@ -122,8 +123,15 @@
trustedLabelPipeline: true,
});
expect(fromObjectMap.repositories.map((repo) => repo.repo)).toEqual(["JSONbored/gittensory"]);
expect(fromObjectMap.repositories[0]).toMatchObject({
repo: "JSONbored/gittensory",
issueDiscoveryShare: DEFAULT_ISSUE_DISCOVERY_SHARE,
});
expect(fromArray.repositories.map((repo) => repo.repo)).toEqual(["JSONbored/gittensory", "bad/numbers"]);
expect(fromArray.repositories.find((repo) => repo.repo === "bad/numbers")).toMatchObject({ emissionShare: 0, issueDiscoveryShare: 0.5 });
expect(fromArray.repositories.find((repo) => repo.repo === "bad/numbers")).toMatchObject({
emissionShare: 0,
issueDiscoveryShare: DEFAULT_ISSUE_DISCOVERY_SHARE,
});
expect(empty.repoCount).toBe(0);
});

Expand Down
Loading
Loading