Merge pull request 'Keep beta Rules at cutover, fall back when a kind is typed, and replace the terms license claim' (#115) from adilallo/fix/product-leftovers into main
Reviewed-on: #115
This commit was merged in pull request #115.
This commit is contained in:
commit
38354a1910
11 files changed
+195
-74
No files matched your search
@@ -0,0 +1,33 @@
|
||||
"use client";
|
||||
|
||||
import { useCallback, useState } from "react";
|
||||
import AskOrganizerInquiryModal from "../../components/modals/AskOrganizerInquiry";
|
||||
|
||||
const LINK_CLASS =
|
||||
"cursor-pointer border-none bg-transparent p-0 font-[inherit] text-[inherit] underline decoration-solid underline-offset-2 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2";
|
||||
|
||||
type LegalAskOrganizerLinkProps = {
|
||||
label: string;
|
||||
};
|
||||
|
||||
/** Inline legal-page control that opens the Ask an organizer dialog. */
|
||||
export default function LegalAskOrganizerLink({
|
||||
label,
|
||||
}: LegalAskOrganizerLinkProps) {
|
||||
const [open, setOpen] = useState(false);
|
||||
const openInquiry = useCallback(() => setOpen(true), []);
|
||||
const closeInquiry = useCallback(() => setOpen(false), []);
|
||||
|
||||
return (
|
||||
<>
|
||||
<button
|
||||
type="button"
|
||||
className={LINK_CLASS}
|
||||
onClick={openInquiry}
|
||||
>
|
||||
{label}
|
||||
</button>
|
||||
<AskOrganizerInquiryModal isOpen={open} onClose={closeInquiry} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import { getRequestSiteOrigin } from "../../../lib/requestSiteOrigin";
|
||||
import { absoluteSiteUrl } from "../../../lib/siteMetadata";
|
||||
import { isPrivacyPolicyEnabled } from "../../../lib/privacyPolicyEnabled";
|
||||
import ContentBanner from "../../components/sections/ContentBanner";
|
||||
import LegalAskOrganizerLink from "./LegalAskOrganizerLink";
|
||||
|
||||
type LegalDocumentPageProps = {
|
||||
slug: LegalDocumentSlug;
|
||||
@@ -46,7 +47,10 @@ function LegalInlineText({ text }: { text: string }) {
|
||||
|
||||
const label = match[1];
|
||||
const href = match[2];
|
||||
if (href === "/privacy" && !isPrivacyPolicyEnabled()) {
|
||||
if (href === "dialog:ask-organizer") {
|
||||
nodes.push(<LegalAskOrganizerLink key={key} label={label} />);
|
||||
key += 1;
|
||||
} else if (href === "/privacy" && !isPrivacyPolicyEnabled()) {
|
||||
nodes.push(label);
|
||||
} else if (isSafeHref(href)) {
|
||||
const isInternal = href.startsWith("/") && !href.startsWith("//");
|
||||
|
||||
@@ -153,13 +153,19 @@ apex.
|
||||
per [§6.1](#61-legacy-rules-archive-cr-102).
|
||||
3. `cloudron uninstall` the legacy app at `communityrule.info`.
|
||||
4. `cloudron configure --location communityrule.info` to move the
|
||||
validated staging install to the apex (or `cloudron install`
|
||||
fresh at apex if cleaner).
|
||||
validated staging install to the apex. Do not `cloudron install`
|
||||
a fresh production app: beta Rules, owners, invited readers, and
|
||||
share settings live in the staging Postgres addon and only arrive
|
||||
intact if that app is relocated.
|
||||
5. Re-run `prisma migrate deploy`, re-set production env vars if
|
||||
not preserved by the move, smoke again.
|
||||
4. **Decommission** — see [CR-101](https://linear.app/community-rule/issue/CR-101/backend-decommission-legacy-expressmysql-backend).
|
||||
Hold the final LAMP backup ≥ 90 days for safety.
|
||||
|
||||
Cutover checks already on the calendar: 30 Nov (beta gate on staging),
|
||||
14 Dec (staging check before the holiday freeze), 12 Jan 2027 (cutover
|
||||
check). The window itself is 19 Jan 2027.
|
||||
|
||||
### Why not in-place?
|
||||
|
||||
Uninstalling the legacy app and installing the new one at apex
|
||||
@@ -181,10 +187,16 @@ Product decisions (closed):
|
||||
tables to a new read-only Gitea repo on `git.medlab.host` (see
|
||||
[§6.1](#61-legacy-rules-archive-cr-102)). Tracked in
|
||||
[CR-102](https://linear.app/community-rule/issue/CR-102/backend-decide-fate-of-legacy-rules-table-read-only-export).
|
||||
3. **Beta Rules carry with the staging app.** The 19 Jan 2027 cutover
|
||||
relocates the staging Cloudron app and its Postgres addon to the
|
||||
apex, so Rules entered during the winter beta keep their owners,
|
||||
invited readers, and share settings. Beta communities enter on
|
||||
staging from the week of 4 Jan 2027. A fresh production install
|
||||
would drop that data.
|
||||
|
||||
Infra decision closed:
|
||||
|
||||
3. **Container registry — Gitea Container Registry on `git.medlab.host`.**
|
||||
4. **Container registry — Gitea Container Registry on `git.medlab.host`.**
|
||||
Same host as Cloudron (`193.46.198.90`). The
|
||||
[`CommunityRule/community-rule`](https://git.medlab.host/CommunityRule/community-rule)
|
||||
repo must be **public** so the container package inherits public visibility
|
||||
|
||||
@@ -12,6 +12,7 @@ import jobsFile from "../../data/create/customRule/_jobs.json";
|
||||
import membershipFacets from "../../data/create/customRule/membership.json";
|
||||
import type {
|
||||
CardEngineEntry,
|
||||
CardFacets,
|
||||
DeckEngine,
|
||||
DeckId,
|
||||
DeckRecommendation,
|
||||
@@ -53,20 +54,24 @@ interface Evaluated {
|
||||
otherKindHits: number;
|
||||
}
|
||||
|
||||
/** Normalizes setup answers. A group with other kinds and no main kind gets the first as main. */
|
||||
/** A typed or missing main kind stays unset so eligibility falls back to size. */
|
||||
export function normalizeAnswers(answers: GroupAnswers): Required<GroupAnswers> {
|
||||
const others = [...(answers.otherKinds ?? [])];
|
||||
const mainKind = answers.mainKind ?? others.shift() ?? null;
|
||||
const mainKind = answers.mainKind ?? null;
|
||||
return {
|
||||
size: answers.size ?? null,
|
||||
mainKind,
|
||||
otherKinds: others.filter((k) => k !== mainKind),
|
||||
otherKinds: [...(answers.otherKinds ?? [])].filter((k) => k !== mainKind),
|
||||
scale: [...new Set(answers.scale ?? [])],
|
||||
stage: answers.stage ?? null,
|
||||
traits: answers.traits ?? {},
|
||||
};
|
||||
}
|
||||
|
||||
function kindFits(orgType: CardFacets["orgType"], kind: Kind | null): boolean {
|
||||
if (!kind || !(kind in orgType)) return true;
|
||||
return orgType[kind];
|
||||
}
|
||||
|
||||
function sizeBandOf(size: string | null, data: DeckData): SizeBand | null {
|
||||
if (!size) return null;
|
||||
const band = data.config.sizeAnswers[size];
|
||||
@@ -86,7 +91,7 @@ function evaluate(
|
||||
if (!f || !entry) throw new Error(`Card ${id} is missing from the facet or jobs file`);
|
||||
const traits = entry.traits ?? {};
|
||||
const fitsSize = band ? f.size[band] : true;
|
||||
const fitsKind = a.mainKind ? f.orgType[a.mainKind] : true;
|
||||
const fitsKind = kindFits(f.orgType, a.mainKind);
|
||||
const openedBy = (traits.opens ?? []).find((k) => ticked.has(k));
|
||||
const isBeside = (traits.beside ?? []).length > 0;
|
||||
// Each facet group counts once. Scale earns its point only if the card fits
|
||||
@@ -96,7 +101,7 @@ function evaluate(
|
||||
const fitsAnswer = (traits.fits ?? []).find((k) => ticked.has(k));
|
||||
const matched: MatchedFacet[] = [];
|
||||
if (band && fitsSize) matched.push("size");
|
||||
if (a.mainKind && fitsKind) matched.push("kind");
|
||||
if (a.mainKind && a.mainKind in f.orgType && fitsKind) matched.push("kind");
|
||||
if (fitsScale) matched.push("scale");
|
||||
if (fitsStage) matched.push("stage");
|
||||
return {
|
||||
|
||||
+23
-10
@@ -9,8 +9,21 @@ import {
|
||||
import type { GroupAnswers, Kind, Scale, Stage, TraitKey } from "./deckTypes";
|
||||
import { KINDS, SCALES, STAGES, TRAIT_KEYS } from "./deckTypes";
|
||||
|
||||
function isKind(value: string): value is Kind {
|
||||
return (KINDS as readonly string[]).includes(value);
|
||||
function isKind(value: string | null | undefined): value is Kind {
|
||||
return value != null && (KINDS as readonly string[]).includes(value);
|
||||
}
|
||||
|
||||
/** First id is the main kind only when it is a catalog kind. A typed kind is no kind. */
|
||||
function kindsFromOrderedIds(ids: readonly string[]): {
|
||||
mainKind: Kind | null;
|
||||
otherKinds: Kind[];
|
||||
} {
|
||||
const mainKind = isKind(ids[0]) ? ids[0] : null;
|
||||
const otherKinds = ids
|
||||
.slice(1)
|
||||
.filter(isKind)
|
||||
.filter((kind, index, all) => kind !== mainKind && all.indexOf(kind) === index);
|
||||
return { mainKind, otherKinds };
|
||||
}
|
||||
|
||||
function isScale(value: string): value is Scale {
|
||||
@@ -36,15 +49,15 @@ export function groupAnswersFromRequestedFacets(
|
||||
facets: RequestedFacets,
|
||||
traits?: Partial<Record<TraitKey, boolean>>,
|
||||
): GroupAnswers {
|
||||
const kinds = (facets.orgType ?? []).filter(isKind);
|
||||
const { mainKind, otherKinds } = kindsFromOrderedIds(facets.orgType ?? []);
|
||||
const scales = (facets.scale ?? []).filter(isScale);
|
||||
const maturity = (facets.maturity ?? [])
|
||||
.map((value) => stageForScoring(value))
|
||||
.filter((value): value is Stage => value !== null);
|
||||
return {
|
||||
size: facets.size?.[0] ?? null,
|
||||
mainKind: kinds[0] ?? null,
|
||||
otherKinds: kinds.slice(1),
|
||||
mainKind,
|
||||
otherKinds,
|
||||
scale: scales,
|
||||
stage: maturity[0] ?? null,
|
||||
traits,
|
||||
@@ -66,9 +79,9 @@ export function groupAnswersFromCreateFlowState(
|
||||
state: CreateFlowState,
|
||||
): GroupAnswers {
|
||||
const size = (state.selectedCommunitySizeIds ?? []).map(resolveSizeChipId)[0] ?? null;
|
||||
const kinds = (state.selectedOrganizationTypeIds ?? [])
|
||||
.map((id) => resolveOrgChipId(id))
|
||||
.filter(isKind);
|
||||
const { mainKind, otherKinds } = kindsFromOrderedIds(
|
||||
(state.selectedOrganizationTypeIds ?? []).map((id) => resolveOrgChipId(id)),
|
||||
);
|
||||
const scale = (state.selectedScaleIds ?? [])
|
||||
.map(resolveScaleChipId)
|
||||
.filter(isScale);
|
||||
@@ -78,8 +91,8 @@ export function groupAnswersFromCreateFlowState(
|
||||
const uniqueScale = [...new Set(scale)];
|
||||
return {
|
||||
size,
|
||||
mainKind: kinds[0] ?? null,
|
||||
otherKinds: kinds.slice(1).filter((kind, index, all) => all.indexOf(kind) === index),
|
||||
mainKind,
|
||||
otherKinds,
|
||||
scale: uniqueScale,
|
||||
stage: maturity[0] ?? null,
|
||||
traits: traitRecord(state.setupTraits),
|
||||
|
||||
@@ -185,9 +185,9 @@
|
||||
"keywords": ["privacy", "personal information", "communityrule"]
|
||||
},
|
||||
"terms": {
|
||||
"title": "Terms of Service",
|
||||
"description": "How you may use CommunityRule, including licenses and the templates API.",
|
||||
"keywords": ["terms of service", "license", "communityrule"]
|
||||
"title": "Our terms are being reviewed",
|
||||
"description": "University counsel is reviewing CommunityRule's terms of service.",
|
||||
"keywords": ["terms of service", "communityrule"]
|
||||
},
|
||||
"cookies": {
|
||||
"title": "Cookies",
|
||||
|
||||
@@ -1,36 +1,14 @@
|
||||
{
|
||||
"_comment": "Terms of service. Owns licenses, API use, and acceptable use. Privacy owns data, hosting, and ranking. Not a substitute for university counsel review.",
|
||||
"_comment": "Interim terms notice while university counsel reviews the policy. No licensing claims about Rules, cards, or templates. Counsel-read copy ships at the 19 Jan 2027 cutover.",
|
||||
"banner": {
|
||||
"title": "Terms of Service",
|
||||
"description": "How you may use CommunityRule, including licenses and the templates API.",
|
||||
"title": "Our terms are being reviewed",
|
||||
"description": "University counsel is reviewing CommunityRule's terms of service.",
|
||||
"author": "Media Economies Design Lab",
|
||||
"date": "2026-08-15"
|
||||
"date": "2026-11-21"
|
||||
},
|
||||
"updated": "Last updated August 15, 2026.",
|
||||
"updated": "Last updated November 21, 2026.",
|
||||
"intro": [
|
||||
"CommunityRule is a toolkit for drafting and publishing community governance documents (“Rules”). It is a project of the [Media Economies Design Lab](https://www.colorado.edu/lab/medlab/) at the University of Colorado Boulder. It is not legal advice."
|
||||
"University counsel is reviewing CommunityRule's terms of service. The reviewed terms will be posted here before CommunityRule launches. Until then, every Rule starts private, and only the people you invite can read it until the person who holds the pen turns on a link. Questions? [Ask an organizer](dialog:ask-organizer)."
|
||||
],
|
||||
"sections": [
|
||||
{
|
||||
"heading": "Licenses",
|
||||
"paragraphs": [
|
||||
"Guides, template copy, and other materials we publish here, and Rules you publish, are licensed [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/). Do not publish material you cannot share under that license.",
|
||||
"CommunityRule is open source. Application source code is [GPL-3.0 or later](https://www.gnu.org/licenses/gpl-3.0.html). You can read and fork it on [Gitea](https://git.medlab.host/CommunityRule/community-rule)."
|
||||
]
|
||||
},
|
||||
{
|
||||
"heading": "Templates API",
|
||||
"paragraphs": [
|
||||
"The curated template library is available as JSON without signing in. [GET /api/templates](/api/templates) lists templates; GET /api/templates/{slug} returns one template. Reuse that copy under CC BY-SA.",
|
||||
"Do not overload this hosted API. If you need your own copy, run the GPL-licensed source yourself."
|
||||
]
|
||||
},
|
||||
{
|
||||
"heading": "Using the service",
|
||||
"paragraphs": [
|
||||
"Do not break, overload, or misuse the site or its APIs. We may suspend access to protect it or other people. The service is offered as-is for research and education; to the extent the law allows, MEDLab and the University of Colorado are not liable for your use of it or of a Rule created here.",
|
||||
"Questions: [medlab@colorado.edu](mailto:medlab@colorado.edu)."
|
||||
]
|
||||
}
|
||||
]
|
||||
"sections": []
|
||||
}
|
||||
+16
-22
@@ -1,5 +1,6 @@
|
||||
import { describe, expect, test, vi } from "vitest";
|
||||
import { screen } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { renderWithProviders as render } from "../utils/test-utils";
|
||||
import PrivacyPage from "../../app/(marketing)/privacy/page";
|
||||
import LegalDocumentPage from "../../app/(marketing)/_components/LegalDocumentPage";
|
||||
@@ -111,38 +112,31 @@ describe("legal document pages", () => {
|
||||
);
|
||||
});
|
||||
|
||||
test("terms page covers licenses and the templates API, not ranking", async () => {
|
||||
test("terms page is a counsel-review notice with no licensing claim", async () => {
|
||||
const user = userEvent.setup();
|
||||
await renderLegalPage("terms", messages.pages.terms);
|
||||
const page = messages.pages.terms;
|
||||
|
||||
expect(
|
||||
screen.getByRole("heading", { level: 1, name: page.banner.title }),
|
||||
).toBeInTheDocument();
|
||||
expect(page.banner.title).toBe("Our terms are being reviewed");
|
||||
expect(page.intro.join(" ")).not.toMatch(/CC BY-SA/i);
|
||||
expect(page.intro.join(" ")).not.toMatch(/licensed/i);
|
||||
expect(page.sections).toEqual([]);
|
||||
expect(screen.queryByRole("heading", { name: "Licenses" })).not.toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByRole("heading", { level: 2, name: "Licenses" }),
|
||||
).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByRole("heading", { level: 2, name: "Templates API" }),
|
||||
).toBeInTheDocument();
|
||||
expect(
|
||||
screen.queryByRole("heading", { name: "Recommendations" }),
|
||||
screen.queryByRole("heading", { name: "Templates API" }),
|
||||
).not.toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByRole("link", { name: "CC BY-SA 4.0" }),
|
||||
).toHaveAttribute(
|
||||
"href",
|
||||
"https://creativecommons.org/licenses/by-sa/4.0/",
|
||||
);
|
||||
screen.getByText(/every Rule starts private/),
|
||||
).toBeInTheDocument();
|
||||
|
||||
await user.click(screen.getByRole("button", { name: "Ask an organizer" }));
|
||||
expect(screen.getByRole("dialog")).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByRole("link", { name: "GPL-3.0 or later" }),
|
||||
).toHaveAttribute("href", "https://www.gnu.org/licenses/gpl-3.0.html");
|
||||
expect(screen.getByRole("link", { name: "Gitea" })).toHaveAttribute(
|
||||
"href",
|
||||
"https://git.medlab.host/CommunityRule/community-rule",
|
||||
);
|
||||
expect(
|
||||
screen.getByRole("link", { name: "GET /api/templates" }),
|
||||
).toHaveAttribute("href", "/api/templates");
|
||||
screen.getByRole("heading", { name: "Ask an organizer" }),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
test("cookies settings page explains there are no optional cookies", async () => {
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { deckData, recommendDeck } from "../../lib/create/deckRecommend";
|
||||
import type { Kind } from "../../lib/create/deckTypes";
|
||||
|
||||
describe("recommendDeck typed main kind", () => {
|
||||
const sizeOnly = {
|
||||
size: "sixToTwelve",
|
||||
mainKind: null,
|
||||
};
|
||||
|
||||
it("treats a typed main kind as no kind so eligibility falls back to size", () => {
|
||||
const typed = recommendDeck(deckData("decisionApproaches"), {
|
||||
size: "sixToTwelve",
|
||||
mainKind: "streetMedicCrew" as Kind,
|
||||
});
|
||||
const none = recommendDeck(deckData("decisionApproaches"), sizeOnly);
|
||||
const coop = recommendDeck(deckData("decisionApproaches"), {
|
||||
size: "sixToTwelve",
|
||||
mainKind: "workersCoop",
|
||||
});
|
||||
|
||||
expect(typed.fallback).toBe(false);
|
||||
expect(typed.recommended.map((card) => card.id)).toEqual(
|
||||
none.recommended.map((card) => card.id),
|
||||
);
|
||||
expect(
|
||||
typed.recommended.some(
|
||||
(card) =>
|
||||
(card.reason.kind === "fit" || card.reason.kind === "opened") &&
|
||||
card.reason.matched.includes("kind"),
|
||||
),
|
||||
).toBe(false);
|
||||
expect(
|
||||
coop.recommended.some(
|
||||
(card) =>
|
||||
(card.reason.kind === "fit" || card.reason.kind === "opened") &&
|
||||
card.reason.matched.includes("kind"),
|
||||
),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("keeps other catalog kinds as ranking hints, not as the main kind", () => {
|
||||
const typedWithOther = recommendDeck(deckData("decisionApproaches"), {
|
||||
size: "sixToTwelve",
|
||||
mainKind: null,
|
||||
otherKinds: ["workersCoop"],
|
||||
});
|
||||
const none = recommendDeck(deckData("decisionApproaches"), sizeOnly);
|
||||
|
||||
expect(typedWithOther.fallback).toBe(false);
|
||||
expect(new Set(typedWithOther.recommended.map((card) => card.job))).toEqual(
|
||||
new Set(none.recommended.map((card) => card.job)),
|
||||
);
|
||||
expect(
|
||||
typedWithOther.recommended.some(
|
||||
(card) =>
|
||||
(card.reason.kind === "fit" || card.reason.kind === "opened") &&
|
||||
card.reason.matched.includes("kind"),
|
||||
),
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -19,6 +19,15 @@ describe("maturity and chip aliases", () => {
|
||||
expect(answers.mainKind).toBe("workersCoop");
|
||||
});
|
||||
|
||||
it("treats a typed main kind as no kind and keeps catalog kinds as other kinds", () => {
|
||||
const answers = groupAnswersFromCreateFlowState({
|
||||
selectedCommunitySizeIds: ["sixToTwelve"],
|
||||
selectedOrganizationTypeIds: ["custom-tenants-union", "workersCoop"],
|
||||
});
|
||||
expect(answers.mainKind).toBeNull();
|
||||
expect(answers.otherKinds).toEqual(["workersCoop"]);
|
||||
});
|
||||
|
||||
it("passes ticked setup answers through as traits", () => {
|
||||
const answers = groupAnswersFromCreateFlowState({
|
||||
setupTraits: { employer: true, records: false },
|
||||
|
||||
@@ -55,6 +55,17 @@ describe("listMethodRecommendations", () => {
|
||||
expect(findManyMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("still ranks when only size is set and the main kind is missing", async () => {
|
||||
const result = await listMethodRecommendations({
|
||||
section: "decisionApproaches",
|
||||
facets: {
|
||||
size: ["sixToTwelve"],
|
||||
},
|
||||
});
|
||||
expect(result?.rankedSlugs.length).toBeGreaterThan(0);
|
||||
expect(findManyMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("uses only the main kind for eligibility", async () => {
|
||||
const result = await listMethodRecommendations({
|
||||
section: "decisionApproaches",
|
||||
|
||||
Reference in new issue
Block a user