Skip to content

Prepare DrFed for collaborative development#14

Merged
dahlia merged 16 commits into
fedify-dev:mainfrom
dahlia:main
Jun 22, 2026
Merged

Prepare DrFed for collaborative development#14
dahlia merged 16 commits into
fedify-dev:mainfrom
dahlia:main

Conversation

@dahlia

@dahlia dahlia commented Jun 20, 2026

Copy link
Copy Markdown
Member

This pull request sets up the project so other contributors can work against the same local workflow, package boundaries, and contribution rules.

It adds the first installable server and model packages, wires the GraphQL layer to the database schema, and gives contributors a documented path for building, running, formatting, and reviewing changes.

What changed

  • Added @drfed/models, including the Drizzle schema for accounts, instances, and instance members, database type exports, email normalization, migration support, and the initial generated migration under packages/models/drizzle.
  • Added @drfed/drfed, the main server package with the drfed-server npm binary, Optique-based CLI parsing, PGlite and PostgreSQL database options, automatic migration support, and GraphQL Yoga serving through srvx.
  • Expanded @drfed/graphql with a Pothos schema builder, Drizzle integration, Relay node support, DateTime, Email, and UUID scalars, Account and Instance object types, and an accountByUuid query.
  • Replaced the inline dev task with scripts/dev.mts, which cleans package dist directories, starts recursive tsdown --watch builds, waits for the packages to build, starts the server, and handles shutdown more reliably.
  • Added the contributor guide in CONTRIBUTING.md, with AGENTS.md and CLAUDE.md pointing to it, so people and coding agents read the same project instructions.
  • Added formatting and workspace support through mise.toml, pnpm-workspace.yaml, .oxfmtrc.json, .hongdown.toml, and editor settings under .zed/settings.json.

Checks

  • mise run check
  • mise run build

AI disclosure

scripts/dev.mts and CONTRIBUTING.md were written with GPT-5.5 assistance. The README.md file in each package was written with Claude Sonnet 4.6. assistance. The scripts/bump-versions.mts and scripts/check-versions.mts were written with GLM-5.2 assistance. No AI assistance was used for the other changes in this pull request.

dahlia added 5 commits June 20, 2026 23:33
- New @drfed/models package with Drizzle ORM schema defining accounts,
  instances, and instance_members tables (PostgreSQL), with support for
  both PGlite (local file-based) and PostgreSQL backends, plus
  database/transaction type definitions and an initial migration
- New @drfed/drfed package: main server CLI using srvx and GraphQL
  Yoga, with @optique-based argument parsing for database backend
  selection (--pglite-data-path or --postgres-url), listen address
  (--listen), and migration control (--no-migrate)
- Expanded @drfed/graphql with a Pothos SchemaBuilder integrated with
  the Drizzle plugin for type-safe GraphQL schema generation, and a
  createYogaServer() factory function wiring it all together
- Added .oxfmtrc.json formatter config and .zed/settings.json with
  per-language format-on-save via oxfmt
- Updated mise.toml and pnpm workspace to include the new packages
- Add @pothos/plugin-relay and graphql-scalars dependencies
- Add DateTime, Email, UUID custom scalar types to the schema builder
- Rename PothosTypes to SchemaTypes and add Scalars definition
- Implement Account drizzleNode with UUID, email, created fields
- Add accountByUuid query field
- Refactor Instance to drizzleNode with slug, expires, created fields
- Add normalizeEmail() utility function to @drfed/models
- Export normalizeEmail from @drfed/models package index
Replace the Nushell-based dev task with a Node.js/TypeScript script
(scripts/dev.mts) that provides more robust process management:

- Remove dist directories before starting builds
- Spawn tsdown in watch mode across all packages
- Poll until all packages have built their dist directories
- Start the drfed server once builds are ready
- Propagate SIGINT/SIGTERM gracefully to child process groups,
  with a 5-second timeout before force-killing
- Handle double Ctrl+C with an immediate forced kill
- Cross-platform support (Windows taskkill, Unix process groups)

Also handle SIGINT (in addition to SIGTERM) in the server's main()
to ensure clean shutdown when running under node --watch.

Assisted-by: Codex:gpt-5.5
Document the DrFed development workflow, including mise-based tasks,
package boundaries, AGPL source headers, npm packaging expectations,
and AI usage disclosure rules.

Point AGENTS.md and CLAUDE.md at the same guide, and exclude those
symlinks from Hongdown so Markdown checks validate the source document
once.

Assisted-by: Codex:gpt-5.5
Add package-level tsconfig files with strict no-emit type checking
and allowImportingTsExtensions enabled for local .ts imports.

Wire Node 26 types through the pnpm catalog, add the mise type check,
and update imports that must be type-only under verbatimModuleSyntax.

Also fix the development script's child-process error result typing and
process lookup error handling so it passes the stricter checks.
@dahlia dahlia requested a review from a team June 20, 2026 15:25
@dahlia dahlia self-assigned this Jun 20, 2026
@dahlia dahlia moved this from Todo to In progress in NLnet NGI0 Commons Fund (2026) Jun 20, 2026

@2chanhaeng 2chanhaeng left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! The code and the flow seem solid. I think it would be even better if more documentation for the code were added.

  • CONTRIBUTING.md: descriptions for each package
  • README.md for each package
    • @drfed/models: descriptions for each model and their relationships
    • @drfed/graphql: descriptions for each node

Comment thread .zed/settings.json
Comment thread mise.toml
Comment thread CONTRIBUTING.md
Comment thread packages/graphql/src/account.ts
Comment thread packages/models/src/schema.ts
@dahlia dahlia requested review from 2chanhaeng, dodok8 and sij411 June 21, 2026 03:10
Added a concise README.md to each of the three packages:

- packages/drfed/README.md: documents the CLI options, server
  startup behavior, and source file layout for @drfed/drfed.
- packages/graphql/README.md: documents the custom scalars,
  source layout, and createYogaServer usage for @drfed/graphql.
- packages/models/README.md: documents the database schema,
  source layout, and migration generation for @drfed/models.

Added a Packages section to CONTRIBUTING.md with a table
summarising each package's directory path, npm name, and
one-line description.

Also added README.md to the files list in each package.json
so the documentation is included in published npm packages.

Assisted-by: Claude Code:claude-sonnet-4-6
@dahlia dahlia added this to the DrFed 0.1.0 milestone Jun 21, 2026
@dahlia dahlia linked an issue Jun 21, 2026 that may be closed by this pull request
2chanhaeng
2chanhaeng previously approved these changes Jun 21, 2026

@sij411 sij411 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also change my email in packages to work@kwonjiwon.org ?

Comment thread packages/models/src/schema.ts Outdated
Comment thread packages/drfed/package.json Outdated
Comment thread packages/models/tsconfig.json
Comment thread packages/drfed/package.json
"accounts",
{
id: uuid().primaryKey(),
email: varchar({ length: 255 }).notNull().unique(),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be misunderstanding something, but since the same email can be used across multiple instances, wouldn't it be non-unique? Also, if for virtual accounts, wouldn't it be more efficient not to have an email at all, so making it nullable would be better?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you're misunderstanding what this accounts table is for. It represents DrFed accounts who creates instances, not instance actors who belong to an instance.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... OK, now that's clear. But then, I can't understand why the name of the relation table between the accounts and the instances is instance_members. I think instance_creator or ⁦instance_owner (@sij411's idea) is easier to understand.

Add scripts/check-versions.mts and scripts/bump-versions.mts along
with corresponding mise tasks (check:versions and bump) to keep the
shared `version` field across all packages/*/package.json in sync.

check:versions is wired into the check:* group so it runs as part of
`mise run check` and fails when any package diverges, reporting which
packages are at which versions.  `mise run bump <version>` updates every
package's version field at once and prints a summary of the changes.

Document the shared-version policy and the new commands in
CONTRIBUTING.md under a new "Version management" section, and list the
sync check among the checks run by `mise run check`.

fedify-dev#14 (comment)

Assisted-by: OpenCode:glm-5.2
@dahlia dahlia removed the request for review from dodok8 June 22, 2026 05:51
@dahlia dahlia merged commit f8e7518 into fedify-dev:main Jun 22, 2026
dahlia added a commit that referenced this pull request Jun 22, 2026
dahlia added a commit that referenced this pull request Jun 22, 2026
dahlia added a commit that referenced this pull request Jun 22, 2026
dahlia added a commit that referenced this pull request Jun 22, 2026
dahlia added a commit that referenced this pull request Jun 22, 2026
@github-project-automation github-project-automation Bot moved this from In progress to Done in NLnet NGI0 Commons Fund (2026) Jun 22, 2026
dahlia added a commit that referenced this pull request Jun 22, 2026
Prepare DrFed for collaborative development
@dahlia

dahlia commented Jun 22, 2026

Copy link
Copy Markdown
Member Author

Rebased by mistaken; replace commits with merge commit d2141f9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

Setting up the repository

4 participants