Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initiatives: create plugin declaration #1416

Merged
merged 1 commit into from Dec 22, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
103 changes: 103 additions & 0 deletions src/plugins/initiatives/declaration.js
@@ -0,0 +1,103 @@
// @flow

import deepFreeze from "deep-freeze";
import type {PluginDeclaration} from "../../analysis/pluginDeclaration";
import type {NodeType, EdgeType} from "../../analysis/types";
import {NodeAddress, EdgeAddress} from "../../core/graph";

export const nodePrefix = NodeAddress.fromParts(["sourcecred", "initiatives"]);
export const edgePrefix = EdgeAddress.fromParts(["sourcecred", "initiatives"]);

export const initiativeNodeType: NodeType = deepFreeze({
name: "Initiative",
pluralName: "Initiatives",
prefix: NodeAddress.append(nodePrefix, "initiative"),
defaultWeight: 1,
description:
"An initiative supernode, describing a scoped improvement to a project from proposal to completion.",
});

/*
Note on the forward and backward naming convention.
It follows the core/graph.js documentation to use
a <subject> <verb> <object> format to figure out
the directionality.
*/

/**
* An initiative (src) DEPENDS ON (verb) a dependency (dst).
* Forward: depending on something shows the value of the dependency.
* Backward: having a dependency does not endorse the iniative, but does flow
* some cred to incentivize reuse and attribution.
*/
export const dependsOnEdgeType: EdgeType = deepFreeze({
forwardName: "depends on",
backwardName: "is a dependency for",
prefix: EdgeAddress.append(edgePrefix, "dependsOn"),
defaultWeight: {forwards: 1, backwards: 1 / 16},
Beanow marked this conversation as resolved.
Show resolved Hide resolved
description: "Connects an initiative to it's dependencies.",
});

/**
* An initiative (src) REFERENCES (verb) a reference (dst).
* Forward: referencing from an initiative shows the value of the reference.
* But we assume a reference likely needs some refinement to be used by the initiative,
* so it flows less cred than to a dependency.
* Backward: having reference material does not endorse the iniative, but does flow
* some cred to incentivize using existing research and attribution.
*/
export const referencesEdgeType: EdgeType = deepFreeze({
forwardName: "references",
backwardName: "is referenced for",
prefix: EdgeAddress.append(edgePrefix, "references"),
defaultWeight: {forwards: 1 / 2, backwards: 1 / 16},
description: "Connects an initiative to it's references.",
});

/**
* A contribution (src) CONTRIBUTES TO (verb) an initiative (dst).
* Forward: a contribution towards the initiative is also an endorsement of the
* value of that initiative.
* Backward: an initiative in large part consists of it's contributions, so the
* value of an initiative caries over to it's contributions.
*/
export const contributesToEdgeType: EdgeType = deepFreeze({
forwardName: "contributes to",
backwardName: "is contributed to by",
prefix: EdgeAddress.append(edgePrefix, "contributesTo"),
defaultWeight: {forwards: 1, backwards: 1},
description: "Connects an initiative to it's contributions.",
});

/**
* A user (src) CHAMPIONS (verb) an initiative (dst).
* Meaning forward is the user claiming and committing they will champion an
* initiative. And backward is the return of cred based on the completion and
* succesful championing of the ininiative.
*
* Forward: a user championing an iniative is also an endorsement of the value
* of that initiative.
* Backward: an initiative likely received a lot of ongoing support from it's
* champion. We're assuming this is more support than individual contributions.
*/
export const championsEdgeType: EdgeType = deepFreeze({
forwardName: "champions",
backwardName: "is championed by",
prefix: EdgeAddress.append(edgePrefix, "champions"),
defaultWeight: {forwards: 1, backwards: 4},
description: "Connects an initiative to users who champion it.",
});

export const declaration: PluginDeclaration = deepFreeze({
name: "Initiatives",
nodePrefix,
edgePrefix,
nodeTypes: [initiativeNodeType],
edgeTypes: [
dependsOnEdgeType,
referencesEdgeType,
contributesToEdgeType,
championsEdgeType,
],
userTypes: [],
});