~ knotless Search/
↑↓ move↵ open⇧↵ all results
0
0

Lexicons nothing refers to may go while none is published

Merged chadtmiller.com asked to merge into main from chadtmiller.com/group-host:lexicons/unused
harness/lexicons.mjs+35−3
@@ -165,7 +165,9 @@ const loosened = (before, after, path) => {
const was = new Set(before.required ?? [])
for (const r of after.required ?? []) if (!was.has(r)) say(path, `${r} is required now: only new optional fields`)
for (const [k, v] of Object.entries(before.properties ?? {})) {
if (!after.properties?.[k]) say(`${path}.${k}`, 'a field is never removed or renamed')
if (!after.properties?.[k]) {
if (!mayGo(path, k)) say(`${path}.${k}`, 'a field is never removed or renamed')
}
else loosened(v, after.properties[k], `${path}.${k}`)
}
loosened(before.items, after.items, `${path}[]`)
@@ -182,19 +184,49 @@ const loosened = (before, after, path) => {
// change may remove: what is said of each is why.
const RETIRED = new Set([])
// None of ours is published yet, so nothing out there was written to it.
// Until one is, a schema, a def or a field may go when nothing here refers
// to it: no lexicon refs it, and the code never names it. One still used
// stays, as it would once published. Set this once the first is published.
const PUBLISHED = false
/// What the code reads: the host, the command, the console and the harness.
const code = git('ls-files', '--', 'crates', 'web/src', 'harness')
.split('\n')
.filter((f) => /\.(rs|ts|svelte|mjs|js)$/.test(f) && !f.startsWith('web/src/lib/lexicons') && f !== 'harness/lexicons.mjs')
.map((f) => readFileSync(join(root, f), 'utf8'))
.join('\n')
/// Whether a def (`nsid#name`, or a schema's `nsid`) is referred to: by a
/// ref in any lexicon, `#name` within its own, or by name in the code.
const referred = (id) => {
const [nsid, name] = id.split('#')
for (const doc of now.values()) {
const text = JSON.stringify(doc)
if (doc.id === nsid ? name && text.includes(`"#${name}"`) : text.includes(`"${id}`)) return true
}
return code.includes(id)
}
/// Whether a removal goes unremarked: of one of ours, nothing published,
/// and nothing referring to it. A field is referred to by its name, quoted.
const mayGo = (id, field) => ours(id.split('#')[0]) && !PUBLISHED && (field ? !code.includes(`"${field}"`) : !referred(id))
if (base) {
const listed = git('ls-tree', '-r', '--name-only', base, '--', 'lexicons').split('\n').filter((f) => f.endsWith('.json'))
for (const file of listed) {
const before = JSON.parse(git('show', `${base}:${file}`))
const after = now.get(file)
if (!after && RETIRED.has(before.id)) continue
if (!after && (RETIRED.has(before.id) || mayGo(before.id))) continue
if (!after) {
say(before.id, `removed since ${base}`)
continue
}
for (const [name, def] of Object.entries(before.defs ?? {})) {
const at = `${before.id}#${name}`
if (!after.defs?.[name]) say(at, `removed since ${base}`)
if (!after.defs?.[name]) {
if (!mayGo(at)) say(at, `removed since ${base}`)
}
else loosened(def, after.defs[name], at)
// A scope naming a space type alone is granted the collections its
// lexicon lists, so taking one out takes writes from those logins.
lexicons/fyi/opensocial/basePermissions.jsondeleted+0−126
@@ -1,126 +0,0 @@
{
"lexicon": 1,
"id": "fyi.opensocial.basePermissions",
"defs": {
"main": {
"type": "permission-set",
"title": "Groups",
"detail": "See your groups, take part in them, act for groups where you hold a role, and let apps sign in as them",
"permissions": [
{
"type": "permission",
"resource": "space",
"spaceType": "fyi.opensocial.meta",
"authority": "*",
"skey": "self",
"action": [
"read"
]
},
{
"type": "permission",
"resource": "space",
"spaceType": "fyi.opensocial.members",
"authority": "*",
"skey": "self",
"collection": [
"fyi.opensocial.acceptance"
],
"action": [
"read",
"create",
"update",
"delete"
]
},
{
"type": "permission",
"resource": "space",
"spaceType": "fyi.opensocial.inbox",
"authority": "*",
"skey": "self",
"collection": [
"fyi.opensocial.invite"
],
"action": [
"read",
"create",
"update",
"delete"
],
"manage": [
"create"
]
},
{
"type": "permission",
"resource": "rpc",
"inheritAud": true,
"lxm": [
"fyi.opensocial.createGroup",
"fyi.opensocial.provisionGroup",
"fyi.opensocial.createSpace",
"fyi.opensocial.assignRoles",
"fyi.opensocial.ejectMember",
"fyi.opensocial.listGroups",
"fyi.opensocial.getGroup",
"fyi.opensocial.getActor",
"fyi.opensocial.getGroupAuth",
"fyi.opensocial.createInvite",
"fyi.opensocial.requestJoin",
"fyi.opensocial.listInvites",
"fyi.opensocial.revokeInvite",
"fyi.opensocial.getAuthorization",
"fyi.opensocial.approveAuthorization",
"fyi.opensocial.declineAuthorization",
"fyi.opensocial.getSpaceBlob",
"fyi.opensocial.getActorInvites",
"fyi.opensocial.declineInvite",
"fyi.opensocial.updateProfile",
"fyi.opensocial.putRole",
"fyi.opensocial.deleteRole",
"fyi.opensocial.putRule",
"fyi.opensocial.deleteRule",
"fyi.opensocial.applyLabel",
"fyi.opensocial.negateLabel",
"fyi.opensocial.listSubjects",
"fyi.opensocial.getSubjectHistory",
"fyi.opensocial.resolveSubject",
"fyi.opensocial.getJoinRequest",
"fyi.opensocial.listJoinRequests",
"fyi.opensocial.admitMember",
"fyi.opensocial.denyJoinRequest",
"fyi.opensocial.cancelJoinRequest",
"fyi.opensocial.leaveGroup",
"fyi.opensocial.updateSpace",
"fyi.opensocial.deleteSpace",
"fyi.opensocial.uploadImage",
"fyi.opensocial.listGroupTokens",
"fyi.opensocial.revokeGroupToken",
"fyi.opensocial.createAppPassword",
"fyi.opensocial.listAppPasswords",
"fyi.opensocial.revokeAppPassword",
"fyi.opensocial.migratePrepare",
"fyi.opensocial.migrateComplete",
"fyi.opensocial.checkImport",
"fyi.opensocial.importAccount",
"fyi.opensocial.importAccountSpace",
"fyi.opensocial.completeImport",
"fyi.opensocial.deactivateGroup",
"fyi.opensocial.activateGroup",
"fyi.opensocial.deleteGroup",
"fyi.opensocial.listRecoveryKeys",
"fyi.opensocial.addRecoveryKey",
"fyi.opensocial.removeRecoveryKey",
"fyi.opensocial.checkGroupHandle",
"fyi.opensocial.updateGroupHandle",
"fyi.opensocial.listSpaceRecords",
"fyi.opensocial.listConnectedApps",
"fyi.opensocial.getActorGroups"
]
}
],
"description": "What an app asks a member for to take part in their groups, and to act for those where they hold a role."
}
}
}
lexicons/fyi/opensocial/defs.json+0−19
@@ -614,25 +614,6 @@
}
}
},
"file": {
"type": "object",
"description": "One file, by its path among the rest: a page, a script, a stylesheet, JSON (a lexicon), an image or a font. What it is served as follows its path's extension.",
"required": [
"path",
"file"
],
"properties": {
"path": {
"type": "string",
"maxLength": 256,
"description": "Where it is among the rest: `events/calendar.html`."
},
"file": {
"type": "blob",
"maxSize": 5000000
}
}
},
"action": {
"type": "string",
"knownValues": [
lexicons/fyi/opensocial/migrateExport.json+0−4
@@ -27,10 +27,6 @@
"cid": {
"type": "string",
"format": "cid"
},
"leaving": {
"type": "boolean",
"description": "For a move to a plain PDS: a space's meta archive as a memberspace whose member list is who may use it now, read and write as their roles allow, so that PDS keeps them in without asking this host."
}
}
},
AGENTS.md+3−1
@@ -95,7 +95,9 @@ right, and come before the code they test.
## Lexicons
The schemas under `lexicons/` are this host's to change until they are
published from here.
published from here. Until then, `just lex` lets a schema, def or field
go when nothing here refers to it; `PUBLISHED` in `harness/lexicons.mjs`
turns that off once the first is published.
Once one is published, it is evolved, never changed, with new fields
optional and nothing removed, renamed, retyped, made required or narrowed.
Every schema of ours (`fyi.opensocial.*`) follows the Lexicon Style Guide